-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
install.sh
executable file
·115 lines (96 loc) · 3.06 KB
/
install.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
#!/usr/bin/env bash
echo -e ""
echo -e "\e[97mThis script installs the theme in the default paths\e[0m"
echo -e "\e[1m\e[32m==> \e[97m\e[100m/boot/grub\e[0m"
echo -e "and"
echo -e "\e[1m\e[32m==> \e[97m\e[100m/boot/grub2\e[0m"
echo -e "and compile this in the same paths with the command"
echo -e "\e[1m\e[34m-> \e[97m\e[100mgrub-mkconfig -o /boot/grub/grub.cfg\e[0m"
echo -e "or"
echo -e "\e[1m\e[34m-> \e[97m\e[100mgrub2-mkconfig -o /boot/grub2/grub.cfg\e[0m"
echo -e ""
echo -e "\e[5m\e[44mif you use a custom path for your Grub"
echo -e "you need to adjust this script or theme to your needs...\e[0m"
echo -e ""
git --version 2>&1 >/dev/null
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -ne 0 ]; then
echo -e "Git command is not installed, please install!"
exit 1
fi
rsync -V 2>&1 >/dev/null
RSYNC_IS_AVAILABLE=$?
if [ $RSYNC_IS_AVAILABLE -ne 0 ]; then
echo -e "Rsync command is not installed, please install!"
exit 1
fi
GRUB_NAME=""
UPDATE_GRUB=""
function compile_grub() {
echo -e "\e[1m\e[32m==> \e[97mApplying changes...\e[0m"
${UPDATE_GRUB}
echo -e "\e[1m\e[34m -> \e[97mTheme successfuly applied!"
echo -e "\e[1m\e[34m -> \e[97mRestart your PC to check it out.\e[0m"
sleep 2
}
function update_grub_file() {
grep -v GRUB_THEME </etc/default/grub >/tmp/clean_grub
mv /tmp/clean_grub /etc/default/grub
echo "GRUB_THEME=/boot/${GRUB_NAME}/themes/Atomic/theme.txt" >>/etc/default/grub
}
function copy_atomic_files() {
echo -e "\e[1m\e[32m==> \e[97mDownloading files...\e[0m"
git clone https://github.com/lfelipe1501/Atomic-GRUB2-Theme /tmp/Atomic-GRUB2-Theme
echo -e "\e[1m\e[32m==> \e[97mCopying files...\e[0m"
rsync -uah /tmp/Atomic-GRUB2-Theme/Atomic /boot/${GRUB_NAME}/themes/
}
function get_distro() {
if [ -e /etc/os-release ]; then
source /etc/os-release
if [[ "$ID" =~ (debian|ubuntu|solus) || "$ID_LIKE" =~ (debian|ubuntu) ]]; then
UPDATE_GRUB='update-grub'
elif [[ "$ID" =~ (arch|gentoo) || "$ID_LIKE" =~ (archlinux|gentoo) ]]; then
UPDATE_GRUB='grub-mkconfig -o /boot/grub/grub.cfg'
elif [[ "$ID" =~ (centos|fedora|opensuse) || "$ID_LIKE" =~ (fedora|rhel|suse) ]]; then
UPDATE_GRUB='grub2-mkconfig -o /boot/grub2/grub.cfg'
fi
fi
}
function main() {
# Check user is root
if [ $UID == 0 ]; then
echo "Yes, You are root!"
else
echo "No, You must be root!"
exit 1
fi
get_distro
# Check which grub
if [ -d "/boot/grub" ]; then
GRUB_NAME="grub"
else
GRUB_NAME="grub2"
fi
copy_atomic_files
echo -e "\e[1m\e[97m You must set the theme in your GRUB config file,"
while :; do
if [ "$answer" = "g" ]; then
echo -e "\e[1m\e[97m You didn't give a valid option, try again."
else
read -p " Would you like to do it now? [y/n] " -t 10 answer
echo -e "\e[0m"
if [ "$answer" = "y" ]; then
# backup old grub file
cp /etc/default/grub /tmp/grub$(date '+%m-%d-%y_%H:%M:%S')
update_grub_file
compile_grub
break
elif [ "$answer" = "n" ]; then
break
fi
let answer=g
fi
done
}
main "$@"
exit 0