-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·376 lines (294 loc) · 10.3 KB
/
install.sh
File metadata and controls
executable file
·376 lines (294 loc) · 10.3 KB
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#!/usr/bin/env bash
SCRIPTNAME="$(basename $0)"
SCRIPTDIR="$(dirname "${BASH_SOURCE[0]}")"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# @Author : Jason
# @Contact : casjaysdev@casjay.pro
# @File : install
# @Created : Mon, Dec 31, 2019, 00:00 EST
# @License : WTFPL
# @Copyright : Copyright (c) CasjaysDev
# @Description : installer script for linux
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set functions
if [ -f /usr/local/share/CasjaysDev/scripts/functions/app-installer.bash ]; then
. /usr/local/share/CasjaysDev/scripts/functions/app-installer.bash
elif [ -f "$HOME/.local/share/scripts/functions/app-installer.bash" ]; then
. "$HOME/.local/share/scripts/functions/app-installer.bash"
else
mkdir -p "$HOME/.local/share/scripts/functions"
curl -LSs https://github.com/casjay-dotfiles/scripts/raw/main/functions/app-installer.bash -o "$HOME/.local/share/scripts/functions/app-installer.bash"
. "$HOME/.local/share/scripts/functions/app-installer.bash"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Defaults
# USER
BIN="$HOME/.local/bin"
CONF="$HOME/.config"
SHARE="$HOME/.local/share"
LOGDIR="$HOME/.local/logs"
BACKUPDIR="$HOME/.local/backups/home"
REPO="https://github.com/casjay-themes"
# SYSTEM
SYSBIN="/usr/local/bin"
SYSCONF="/usr/local/etc"
SYSSHARE="/usr/local/share"
SYSLOGDIR="$HOME/.local/logs"
SYSBACKUPDIR="$/usr/local/share/backups"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set options
APPNAME="linux"
PIPNAME=""
PLUGNAME=""
if sudoif ; then
APPDIR="$SYSSHARE/CasjaysDev/themes"
PLUGDIR="$CONF/$APPNAME/$PLUGNAME"
else
APPDIR="$CONF/themes"
PLUGDIR="$CONF/$APPNAME/$PLUGNAME"
fi
PIPVERSION="3"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Requires root
#sudoreq # sudo required
#sudorun # sudo optional
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# prerequisites
APP=""
PKG=""
PIP=""
MISSING=""
PIPMISSING=""
# - - - - - - - - - - - - - - -
for cmd in xfce4-about
do
cmd_exists $cmd || MISSING+="$cmd "
done
# - - - - - - - - - - - - - - -
if [ ! "$(cmd_exists apt)" ]; then PKG="xfce4"
elif [ ! "$(cmd_exists yum)" ]; then PKG="xfce4"
elif [ ! "$(cmd_exists pacman)" ]; then PKG="xfce4"
fi
# - - - - - - - - - - - - - - -
if [ ! -z "$MISSING" ]; then printf_warning "This requires $MISSING"
if cmd_exists "pkmgr"; then
for miss in $PKG
do execute \
"requiresudo pkmgr silent $miss" \
"Attemping install of $miss"
done
fi
fi
# - - - - - - - - - - - - - - -
#cmd_exists PIPNAME || PIPMISSING+="PIPNAME "
# - - - - - - - - - - - - - - -
#if [ ! -z "$PIPMISSING" ]; then printf_warning "This requires $PIPMISSING"
# if cmd_exists "pkmgr"; then
# for pippkg in $PIPMISSING
# do execute "requiresudo pkmgr pip $pippkg" \
# "Attempting to install $pippkg"
# done
# fi
#fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Ensure directories exist
mkd "$BACKUPDIR"
mkd "$CONF/CasjaysDev/apps"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main progam
if [ -d "$APPDIR/.git" ]; then
execute \
"cd $APPDIR && \
git_update" \
"Updating $APPNAME configurations"
else
if [ -d "$BACKUPDIR/$APPNAME" ]; then
rm_rf "$BACKUPDIR"/"$APPNAME"
fi
execute \
"mv_f $APPDIR $BACKUPDIR/$APPNAME && \
git_clone -q $REPO/$APPNAME $APPDIR" \
"Installing $APPNAME configurations"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Plugins
#if [ -d "$PLUGDIR"/.git ]; then
# execute \
# "cd $PLUGDIR && git_update" \
# "Installing NAME for $APPNAME"
#else
# execute \
# "git_clone GITREPO $PLUGDIR" \
# "Plugin NAME has been installed\n"
#fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# run post install scripts
if sudoif; then
execute \
"sudo cp -Rf $APPDIR/icons/* /usr/share/icons && \
sudo fc-cache -f /usr/share/icons/N.I.B./ && \
sudo fc-cache -f /usr/share/icons/Obsidian-Purple/" \
"Installing icons"
sudo find /usr/share/icons -mindepth 1 -maxdepth 1 -type d | while read -r THEME; do
if [ -f "$THEME/index.theme" ]; then
execute \
"gtk-update-icon-cache -f -q $THEME" \
"Updating ICON $THEME"
fi
done
else
if [ -L ~/.local/share/icons ]; then unlink ~/.local/share/icons ; fi
if [ -d ~/.local/share/icons ] && [ ! -L ~/.local/share/icons ]; then
mv -f ~/.local/share/icons ~/.local/share/icons.old
fi
if [ -d ~/.local/share/icons.old ]; then
execute \
"ln -sf $APPDIR/icons ~/.local/share/icons && \
rsync -aqh ~/.local/share/icons.old/* ~/.local/share/icons/ 2>/dev/null && \
rm -Rf ~/.local/share/icons.old/ && \
fc-cache -f ~/.local/share/icons/N.I.B./ && \
fc-cache -f ~/.local/share/icons/Obsidian-Purple/" \
"$APPDIR/icons → ~/.local/share/icons"
else
execute \
"ln -sf $APPDIR/icons ~/.local/share/icons && \
fc-cache -f ~/.local/share/icons/N.I.B./ && \
fc-cache -f ~/.local/share/icons/Obsidian-Purple/" \
"$APPDIR/icons → ~/.local/share/icons"
fi
find ~/.local/share/icons/ -mindepth 1 -maxdepth 1 -type d | while read -r THEME; do
if [ -f "$THEME/index.theme" ]; then
execute \
"gtk-update-icon-cache -f -q $THEME" \
"Updating ICON $THEME"
fi
done
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if sudoif; then
execute \
"sudo cp -Rf $APPDIR/themes/* /usr/share/themes" \
"Installing themes"
else
if [ -L ~/.local/share/themes ]; then unlink ~/.local/share/themes ; fi
if [ -d ~/.local/share/themes ] && [ ! -L ~/.local/share/themes ]; then
mv -f ~/.local/share/themes ~/.local/share/themes.old
fi
if [ -d ~/.local/share/themes.old ]; then
execute \
"ln -sf $APPDIR/themes ~/.local/share/themes && \
rsync -ahq ~/.local/share/themes.old/* ~/.local/share/themes/ 2>/dev/null && \
rm -Rf ~/.local/share/themes.old/"
"$APPDIR/themes → ~/.local/share/themes"
else
execute \
"ln -sf $APPDIR/themes ~/.local/share/themes" \
"$APPDIR/themes → ~/.local/share/themes"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if sudoif ; then
execute \
"sudo cp -Rf $APPDIR/fonts/* /usr/share/fonts" \
"Installing fonts"
else
if [ -L ~/.local/share/fonts ]; then unlink ~/.local/share/fonts ; fi
if [ -d ~/.local/share/fonts ] && [ ! -L ~/.local/share/fonts ]; then
mv -f ~/.local/share/fonts ~/.local/share/fonts.old
fi
if [ -d ~/.local/share/fonts.old ]; then
execute \
"ln -sf $APPDIR/fonts ~/.local/share/fonts && \
rsync -ahq ~/.local/share/fonts.old/* ~/.local/share/fonts/ 2>/dev/null && \
rm -Rf ~/.local/share/fonts.old/ && \
fc-cache -f" \
"$APPDIR/fonts → ~/.local/share/fonts"
else
execute \
"ln -sf $APPDIR/fonts ~/.local/share/fonts && \
fc-cache -f" \
"$APPDIR/fonts → ~/.local/share/fonts"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if sudoif ; then
if [ -f /usr/sbin/grub-mkconfig ]; then
GRUB="/usr/sbin/grub-mkconfig"
else
GRUB="/usr/sbin/grub2-mkconfig"
fi
if [ -f /boot/grub/grub.cfg ]; then
if [ ! -d /boot/grub/themes ]; then
sudo mkdir -p /boot/grub/themes
fi
execute \
"sudo cp -Rf $APPDIR/boot/grub /etc/default/grub && \
sudo cp -Rf $APPDIR/boot/themes/* /boot/grub/themes && \
sudo sed -i 's|^\(GRUB_TERMINAL\w*=.*\)|#\1|' /etc/default/grub && \
sudo sed -i 's|grubdir|grub|g' /etc/default/grub && \
sudo ${GRUB} -o /boot/grub/grub.cfg" \
"Installing grub customizations"
fi
########
if [ -f /boot/grub2/grub.cfg ]; then
if [ ! -d /boot/grub2/themes ]; then
sudo mkdir -p /boot/grub2/themes
fi
execute \
"sudo cp -Rf $APPDIR/boot/grub /etc/default/grub && \
sudo cp -Rf $APPDIR/boot/themes/* /boot/grub2/themes && \
sudo sed -i 's|^\(GRUB_TERMINAL\w*=.*\)|#\1|' /etc/default/grub && \
sudo sed -i 's|grubdir|grub2|g' /etc/default/grub && \
sudo ${GRUB} -o /boot/grub2/grub.cfg" \
"Installing grub customizations"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if sudoif ; then
LXDM=$(which lxdm 2>/dev/null)
if [ -d /usr/share/lightdm-gtk-greeter-settings ]; then
LIGHTDMG=/usr/share/lightdm-gtk-greeter-settings
elif [ -d /usr/share/lightdm-gtk-greeter ]; then
LIGHTDMG=/usr/share/lightdm-gtk-greeter
else
LIGHTDMG=/usr/share/lightdm/lightdm-gtk-greeter.conf.d
fi
if [ -d /etc/lightdm ]; then
execute \
"sudo cp -Rf $APPDIR/login/lightdm/etc/* /etc/lightdm/ && \
sudo cp -Rf $APPDIR/login/lightdm/share/lightdm/* /usr/share/lightdm/ && \
sudo cp -Rf $APPDIR/login/lightdm/share/lightdm-gtk-greeter-settings/* $LIGHTDMG/" \
"Installing lightdm customizations"
fi
########
if [ -d /etc/lxdm ]; then
execute \
"sudo cp -Rf $APPDIR/login/lxdm/share/* /usr/share/lxdm/" \
"Installing lxdm customizations"
fi
if [ ! -z "$LXDM" ]; then
sudo sed -i "s|.*numlock=.*|numlock=1|g" /etc/lxdm/lxdm.conf
sudo sed -i "s|.*bg=.*|bg=/usr/share/lxdm/themes/BlackArch/blackarch.jpg|g" /etc/lxdm/lxdm.conf
sudo sed -i "s|.*tcp_listen=.*|tcp_listen=1|g" /etc/lxdm/lxdm.conf
sudo sed -i "s|gtk_theme=.*|gtk_theme=Arc-Pink-Dark|g" /etc/lxdm/lxdm.conf
sudo sed -i "s|theme=.*|theme=BlackArch|g" /etc/lxdm/lxdm.conf
if [ -f /etc/X11/default-display-manager ]; then
sudo sed -i "s|lightdm|lxdm|g" /etc/X11/default-display-manager
fi
# execute \
# "sudo systemctl disable -f lightdm 2>/dev/null && \
# sudo systemctl enable -f lxdm 2>/dev/null" \
# "Enabling the LXDM login manager"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# create version file
if [ ! -f "$CONF/CasjaysDev/apps/$APPNAME" ] && [ -f "$APPDIR/version.txt" ]; then
ln -s "$APPDIR/version.txt" "$CONF/CasjaysDev/apps/$APPNAME"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# exit
if [ ! -z "$EXIT" ]; then exit "$EXIT"; fi
# end
#/* vim set expandtab ts=4 noai