-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_apps.sh
executable file
·117 lines (91 loc) · 3.17 KB
/
install_apps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# e - script stops on error
# u - error if undefined variable
# o pipefail - script fails if command piped fails
set -euxo pipefail
name=$(cat /tmp/user_name)
apps_path="/tmp/apps.csv"
curl https://raw.githubusercontent.com/carr-james/arch_installer/main/apps.csv > $apps_path
dialog \
--title "Package Installer" \
--msgbox "Welcome! This installer will help you get all the packages you need to get started fast!" \
10 60
apps=("essential" "Essentials" on
"network" "Networking" on
"tools" "Useful Tools (highly recommended)" on
"audio" "Audio" on
"fonts" "Fonts" on
"tmux" "Tmux" on
"notifier" "Notification Tools" on
"git" "Git" on
"i3" "i3 Window Manager" on
"zsh" "The z-shell (zsh)" on
"urxvt" "URxvt (terminal emulator)" on
"neovim" "Neovim" on
"firefox" "Firefox" off)
# TODO: make this nicer rather than hard coded
# groups=($(awk --field-separator ',' '{print $1}' apps.csv | uniq))
# auto_selected_groups=(essentials network tools tmux notifier git i3 zsh neovim urxvt)
# for i in "${!groups[@]}"; do
# group="${groups[$i]}"
#
# # if the current group is in the auto_selected_groups array
# if [[ " ${auto_selected_groups[@]} " =~ " ${group} " ]]; then
# groups[$i]="${groups[$i]} on"
# else
# groups[$i]="${groups[$i]} off"
# fi
# done
# TODO: see if we can enable/disable individual packages on a granular level
message=$(cat <<-EOM
Select the groups of applications you would like to install.
UP/DOWN to move cursor.
SPACE to change selection.
ENTER to confirm selection.
EOM
)
dialog --checklist "$message" \
0 0 0 \
"${apps[@]}" 2> selected_app_groups
selected_app_groups=$(cat selected_app_groups) && rm selected_app_groups
# parse the csv for packages to install
selection="^$(echo $selected_app_groups | sed -e 's/ /,|^/g'),"
lines=$(grep -E "$selection" "$apps_path")
count=$(echo "$lines" | wc -l)
packages=$(echo "$lines" | awk -F, {'print $2'})
# for debugging
echo "$selection" "$lines" "$count" >> "/tmp/packages"
# update the system
pacman -Syu --noconfirm
# installing packages
rm -f /tmp/aur_queue
message=$(cat <<-EOM
The system will now install the selected packages.
This may take a while...
EOM
)
dialog --title "Let's Go!" --msgbox "$message" 13 60
c=0
echo "$packages" | while read -r line; do
c=$(( "$c" + 1))
dialog \
--title "Package Installation" \
--infobox "Installing program $c out of $count: $line..." \
8 70
((pacman --noconfirm --needed -S "$line" > /tmp/arch_install 2>&1) \
|| echo "$line" >> /tmp/aur_queue) \
|| echo "$line" >> /tmp/arch_install_failed
# app specific post install commands
if [ "$line" = "zsh" ]; then
# set zsh as the default shell
chsh -s "$(which zsh)" "$name"
fi
if [ "$line" = "networkmanager" ]; then
systemctl enable NetworkManager.service
fi
done
# add user to sudoers
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
# switch to user and run the user installer
curl https://raw.githubusercontent.com/carr-james/arch_installer/main/install_user.sh > /tmp/install_user.sh;
sudo -u "$name" sh /tmp/install_user.sh