-
Notifications
You must be signed in to change notification settings - Fork 27
/
lib
309 lines (275 loc) · 5.85 KB
/
lib
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/bin/bash
# Arch Linux Desktop Install (archdi)
# -----------------------------------
# author : MatMoul
# https://github.com/MatMoul
# http://sourceforge.net/u/matmoul
# project : https://github.com/MatMoul/archdi
# http://sourceforge.net/projects/archdi/
# license : GPLv3 (http://opensource.org/licenses/GPL-3.0)
apptitle="Arch Linux Desktop Install (archdi) - Version: 2022.11.20.22.42.58 (GPLv3)"
baseurl=https://raw.githubusercontent.com/MatMoul/archdi-pkg/master
cachedir=~/.cache/archdi
cat << EOF > dialog.archfi
use_shadow = OFF
title_color = (BLACK,WHITE,OFF)
button_label_active_color = (WHITE,BLUE,ON)
button_label_inactive_color = (BLACK,WHITE,OFF)
tag_color = (BLACK,WHITE,OFF)
tag_selected_color = (WHITE,BLUE,ON)
tag_key_color = (BLACK,WHITE,OFF)
tag_key_selected_color = (WHITE,BLUE,ON)
check_color = tag_color
check_selected_color = tag_selected_color
EOF
export DIALOGRC="dialog.archfi"
# $1: path
menu(){
require $1 755
$cachedir/$1
if [ $? = 0 ]; then
menu $1
fi
}
# $1: path
script(){
require $1 755
$cachedir/$1
}
# $1: pacman packages
# $2: aur packages
instpkg(){
if [ ! "$1" = "" ]; then
clear
echo "# pacman -S --needed $1"
pacman -S --needed $1
pressanykey
fi
if [ ! "$2" = "" ]; then
if [ -f /usr/bin/trizen ]; then
clear
echo "# sudo -u aurbuilder trizen -S --needed $2"
sudo -u aurbuilder trizen -S --needed $2
pressanykey
else
if [ -f /usr/bin/yay ]; then
clear
echo "# sudo -u aurbuilder yay -S --needed $2"
sudo -u aurbuilder yay -S --needed $2
pressanykey
else
if [ -f /usr/bin/aurman ]; then
clear
echo "# sudo -u aurbuilder aurman -S --needed $2"
sudo -u aurbuilder aurman -S --needed $2
pressanykey
else
if [ -f /usr/bin/yaourt ]; then
clear
echo "# sudo -u aurbuilder yaourt -S --needed $2"
sudo -u aurbuilder yaourt -S --needed $2
pressanykey
else
echo "To install AUR packages, you need to install an aurhelper in updates menu !"
fi
fi
fi
fi
fi
}
# $1: string
# $2: [title]
choosepkg(){
if [ "$2" = "" ]; then
title=$1
else
title=$2
fi
options=()
items=$(pacman -Ssq $1)
for item in $items; do
options+=("$item" "" off)
done
sel=$(dialog --backtitle "$apptitle" --title "$title" --cancel-button "Back" --checklist "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
return 1
fi
for itm in $sel; do
pkg="$pkg $(echo $itm | sed 's/"//g')"
done
instpkg "$pkg" "$aurpkg"
return 0
}
# $1: string
# $2: [title]
chooseaurpkg(){
if [ "$2" = "" ]; then
title=$1
else
title=$2
fi
options=()
if [ -f /usr/bin/trizen ]; then
items=$(trizen -Ssq $1)
else
if [ -f /usr/bin/yay ]; then
items=$(yay -Ssq $1)
else
if [ -f /usr/bin/aurman ]; then
items=$(aurman -Ssq $1)
else
if [ -f /usr/bin/yaourt ]; then
items=$(yaourt -Ssq $1)
fi
fi
fi
fi
for item in $items; do
options+=("$item" "" off)
done
sel=$(dialog --backtitle "$apptitle" --title "$title" --cancel-button "Back" --checklist "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
return 1
fi
for itm in $sel; do
aurpkg="$aurpkg $(echo $itm | sed 's/"//g')"
done
instpkg "$pkg" "$aurpkg"
return 0
}
# $1: path
# $2: chmod
require(){
if [ ! -f "$cachedir/$1" ]; then
path=$(dirname $1)
mkdir -p $cachedir/$path 2> /dev/null
cd $cachedir/$path
curl -LO $baseurl/$1 2> /dev/null
fi
chmod $2 $cachedir/$1
cd $cachedir
}
# $1 : message
# $2 : args
confirm(){
dialog --backtitle "$apptitle" $2 --yesno "$1" 0 0
}
pressanykey(){
read -n1 -p "Press any key to continue."
}
# $1 : filename
editfile(){
editor=$EDITOR
if [ "$editor" == "" ]; then
editor="nano"
fi
if [ ! -f "/usr/bin/$editor" ]; then
editor="nano"
fi
echo "$editor $1"
$editor "$1"
}
# $1 : servicename
# $2 : [displayname]
svcstart(){
if [ "$2" = "" ]; then
displayname="$1"
else
displayname="$2 ($1)"
fi
if (confirm "Start $displayname service ?\n\nsystemctl start $1") then
clear
echo "systemctl start $1"
systemctl start $1
pressanykey
else
exit 1
fi
}
# $1 : servicename
# $2 : [displayname]
svcrestart(){
if [ "$2" = "" ]; then
displayname="$1"
else
displayname="$2 ($1)"
fi
if (confirm "Restart $displayname service ?\n\nsystemctl restart $1") then
clear
echo "systemctl restart $1"
systemctl restart $1
pressanykey
else
exit 1
fi
}
# $1 : servicename
# $2 : [displayname]
svcstop(){
if [ "$2" = "" ]; then
displayname="$1"
else
displayname="$2 ($1)"
fi
if (confirm "Stop $displayname service ?\n\nsystemctl stop $1") then
clear
echo "systemctl stop $1"
systemctl stop $1
pressanykey
else
exit 1
fi
}
# $1 : servicename
# $2 : [displayname]
svcenable(){
if [ "$2" = "" ]; then
displayname="$1"
else
displayname="$2 ($1)"
fi
if (confirm "Start $displayname service at boot ?\n\nsystemctl enable $1") then
clear
echo "systemctl enable $1"
systemctl enable $1
pressanykey
#else
# exit 1
fi
}
# $1 : servicename
# $2 : [displayname]
svcdisable(){
if [ "$2" = "" ]; then
displayname="$1"
else
displayname="$2 ($1)"
fi
if (confirm "Disable $displayname service at boot ?\n\nsystemctl disable $1") then
clear
echo "systemctl disable $1"
systemctl disable $1
pressanykey
#else
# exit 1
fi
}
while (( "$#" )); do
case $1 in
--root)
menu menu
exit 0
;;
--chroot)
require menu 755
sed -i "/options+=(\"Shutdown\" \"\")/d" menu
menu menu
exit 0
;;
esac
shift
done