-
Notifications
You must be signed in to change notification settings - Fork 5
/
installer.sh
executable file
·166 lines (144 loc) · 6.17 KB
/
installer.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
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
#!/usr/bin/env bash
CRE=$(tput setaf 1)
CYE=$(tput setaf 3)
CGR=$(tput setaf 2)
CBL=$(tput setaf 4)
BLD=$(tput bold)
CNC=$(tput sgr0)
backup_folder=~/.RiceBackup
date=$(date +%Y%m%d-%H%M%S)
logo () {
local text="${1:?}"
echo -en "
▒▒▒▒▒▒▒▒▄▄▄▄▄▄▄▄▒▒▒▒▒▒
▒▒█▒▒▒▄██████████▄▒▒▒▒
▒█▐▒▒▒████████████▒▒▒▒
▒▌▐▒▒██▄▀██████▀▄██▒▒▒
▐┼▐▒▒██▄▄▄▄██▄▄▄▄██▒▒▒
▐┼▐▒▒██████████████▒▒▒
▐▄▐████─▀▐▐▀█─█─▌▐██▄▒
▒▒█████──────────▐███▌
▒▒█▀▀██▄█─▄───▐─▄███▀▒
▒▒█▒▒███████▄██████▒▒▒
▒▒▒▒▒██████████████▒▒▒
▒▒▒▒▒█████████▐▌██▌▒▒▒
▒▒▒▒▒▐▀▐▒▌▀█▀▒▐▒█▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▐▒▒▒▒▌▒▒▒▒▒
Ghost 1n TH3 SSH Dotfiles\n\n"
printf ' %s [%s%s %s%s %s]%s\n\n' "${CRE}" "${CNC}" "${CYE}" "${text}" "${CNC}" "${CRE}" "${CNC}"
}
########## ---------- You must not run this as root ---------- ##########
not_sudo () {
if [ "$(id -u)" = 0 ]; then
echo "This script MUST NOT be run as root user."
exit 1
fi
}
########## ---------- Welcome ---------- ##########
welcome () {
logo "Welcome!"
printf '%s%sThis script will check if you have the necessary dependencies, and if not, it will install them. Then, it will clone the RICE in your HOME directory.\nAfter that, it will create a secure backup of your files, and then copy the new files to your computer.\n\nMy dotfiles DO NOT modify any of your system configurations.\nYou will be prompted for your root password to install missing dependencies and/or to switch to zsh shell if its not your default.\n\nThis script doesnt have the potential power to break your system, it only copies files from my repository to your HOME directory.%s\n\n' "${BLD}" "${CRE}" "${CNC}"
while true; do
read -rp " Do you wish to continue? [y/N]: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) printf " Error: just write 'y' or 'n'\n\n";;
esac
done
clear
}
# ########## ---------- Install packages ---------- ##########
requirements () {
logo "Installing requirements..."
packages=(bspwm polybar kitty rofi picom sxhkd lsd feh code firejail neofetch xclip fonts-jetbrains-mono zsh zsh-syntax-highlighting)
printf "%s%s[+] Checking for required packages...%s\n" "${BLD}" "${CBL}" "${CNC}"
for package in "${packages[@]}"
do
if ! apt list --installed "$package" 2>/dev/null | grep -q "$package"; then
printf '\t- Installing %s...%s\n' "$package"
sudo apt install "$package" -y &> /dev/null
else
printf '\t- %s is already installed on your system!\n' "$package"
sleep 1
fi
done
printf '%s[+] All requirements successfully met!%s\n' "$CGR" "$CNC"
sleep 3
clear
}
########## ---------- Preparing Folders ---------- ##########
prepFolders () {
logo "Preparing Folders"
if [ ! -e $HOME/.config/ ]; then
mkdir $HOME/.config/
printf "\t- Creating $HOME/.config/..."
else
printf "\t- $HOME/.config/ already exists."
fi
sleep 2
clear
}
########## ---------- Copy the Rice! ---------- ##########
copyRice () {
logo "Installing dotfiles..."
printf "%s[+] Copying files to respective directories...\n%s" "$CBL" "$CNC"
for folder in ./ghost-rice/*; do
cp -R "${folder}" ~/.config/
if [ $? -eq 0 ]; then
printf "\t-%s folder copied succesfully into '${HOME}/.config/'!%s\n" "${folder}" "${CNC}"
sleep 1
else
printf "\t-%s%s failed to been copied, you must copy it manually%s\n" "${CRE}" "${folder}" "${CNC}"
sleep 1
fi
done
for folder in ./misc/*; do
cp -R -f "${folder}" ~/.local/share/fonts/
if [ $? -eq 0 ]; then
printf "\t-%s copied succesfully into '${HOME}/.local/share/fonts/'!%s\n" "${folder}" "${CNC}"
sleep 1
else
printf "\t-%s%s failed to been copied, you must copy it manually%s\n" "${CRE}" "${folder}" "${CNC}"
sleep 1
fi
done
fc-cache -rv >/dev/null 2>&1
printf "%s[+] Files copied succesfully!!%s\n" "${CGR}" "${CNC}"
sleep 1
}
########## --------- Changing shell to zsh power10k ---------- ##########
chShell () {
logo "Changing default shell to zsh power10k..."
# Download powerlevel10k
if [ ! -d "~/.config/powerlevel10k" ]; then
git clone --quiet --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/.config/powerlevel10k
fi
# Setup P10K theme and ZSH config
cp -f home/p10k.zsh ~/.p10k.zsh && cp -f home/zshrc ~/.zshrc
if [ $? -eq 0 ]; then
printf "\t-%s files copied succesfully into your home directory!%s\n" "${file}" "${CNC}"
sleep 1
else
printf "\t-%s %s failed to been copied, you must copy it manually%s\n" "${CRE}" "${file}" "${CNC}"
sleep 1
fi
# done
printf "%s%sIf your shell is not zsh will be changed now.\nYour root password is needed to make the change.\n\nAfter that is important for you to reboot.\n %s\n" "${BLD}" "${CRE}" "${CNC}"
if [[ $SHELL != "/usr/bin/zsh" ]]; then
echo "Changing shell to zsh, your root password is needed."
chsh -s /usr/bin/zsh
printf "%s%s[+] Installation finished successfully, now reboot the system.\n%sGood bye!\n" "${BLD}" "${CGR}" "${CNC}"
zsh
else
printf "%s%s[+] Installation finished successfully, now reboot the system.\n%sGood bye!\n" "${BLD}" "${CGR}" "${CNC}"
zsh
fi
}
########## ---------- Execution ---------- ##########
not_sudo
welcome
requirements
prepFolders
copyRice
chShell