-
Notifications
You must be signed in to change notification settings - Fork 5
/
archcraft-fluxbox.install
93 lines (76 loc) · 2.79 KB
/
archcraft-fluxbox.install
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
## Colors ----------------------------
# Text Reset
Color_Off='\033[0m'
# Regular
Black='\033[0;30m' Red='\033[0;31m' Green='\033[0;32m' Yellow='\033[0;33m'
Blue='\033[0;34m' Purple='\033[0;35m' Cyan='\033[0;36m' White='\033[0;37m'
# Bold
BBlack='\033[1;30m' BRed='\033[1;31m' BGreen='\033[1;32m' BYellow='\033[1;33m'
BBlue='\033[1;34m' BPurple='\033[1;35m' BCyan='\033[1;36m' BWhite='\033[1;37m'
## -----------------------------------
## User info
user_name=`echo ${SUDO_USER:-$(whoami)}`
group_id=`echo ${SUDO_GID}`
user_group=`cat /etc/group | grep $group_id | cut -d: -f1 | head -1`
## Packages specific
config_dir="/home/${user_name}"
skel_dir='/etc/skel'
wm_config='.fluxbox'
wm_name='Fluxbox'
current_config="$config_dir/$wm_config"
updated_config="$config_dir/${wm_config}_pacnew_`date +%Y-%m-%d`"
## -----------------------------------
## Copy terminal config in /root
copy_term_cfg_root() {
mkdir -p /root/${wm_config} && cp -rf "$skel_dir/$wm_config/alacritty" $_
}
## Install Config files
install_wm_config() {
echo -e ${Blue}"\n[*] Copying ${BBlue}${wm_name}${Blue} config files into ${BBlue}${config_dir}" ${Color_Off}
mkdir -p "$current_config"
cp -rf "$skel_dir/$wm_config"/* "$current_config"/
chown -R ${user_name}:${user_group} "$current_config"
if [[ -d "$current_config" ]]; then
echo -e ${Green}"[*] Configuration files installed successfully!\n" ${Color_Off}
else
echo -e ${Red}"[!] Failed to install configuration files!\n" ${Color_Off}
fi
}
## Update Config files
update_wm_config() {
echo -e ${Blue}"\n[*] Copying latest ${BBlue}${wm_name}${Blue} config files into ${BBlue}${config_dir}" ${Color_Off}
mkdir -p "$updated_config"
cp -rf "$skel_dir/$wm_config"/* "$updated_config"/
chown -R ${user_name}:${user_group} "$updated_config"
if [[ -d "$updated_config" ]]; then
echo -e ${Green}"[*] Latest configuration files installed successfully!" ${Color_Off}
echo -e ${Yellow}"[+] Latest config files are stored in : ${BYellow}${updated_config}${Yellow}" ${Color_Off}
echo -e ${Purple}"[*] To use latest config files, rename ${BPurple}${updated_config}${Purple} to ${BPurple}${current_config}${Purple}\n" ${Color_Off}
else
echo -e ${Red}"[!] Failed to install latest configuration files!\n" ${Color_Off}
fi
}
## -----------------------------------
## Main
run_main() {
if [[ "$user_group" != 'liveuser' ]]; then
if [[ ! -d "$current_config" ]]; then
install_wm_config
else
update_wm_config
fi
fi
}
post_install() {
copy_term_cfg_root
run_main
}
post_upgrade() {
copy_term_cfg_root
run_main
}
post_remove() {
if [[ -d "$current_config" ]]; then
echo -e ${Red}"\n[*] Config files for ${BYellow}${wm_name}${Red} are still available in : ${BGreen}${current_config}${Red} directory. If you want to remove them, Do it manually.\n" ${Color_Off}
fi
}