forked from ChrisTitusTech/Top-5-Bootloader-Themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·176 lines (144 loc) · 5.47 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
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
#!/bin/bash
#/**
# * ChrisTechTips Grub2 Theme Installer
# *
# * @license MIT
# * @author "Chris Titus" <[email protected]>
# * @author "Matthias Morin" <[email protected]>
# * @version 1.0.0
# * @link https://youtu.be/BAyzHP1Cqb0
# */
#THEME_DIR='/usr/share/grub/themes'
THEME_DIR='/boot/grub/themes'
THEME_NAME=''
function echo_title() { echo -ne "\033[1;44;37m${*}\033[0m\n"; }
function echo_caption() { echo -ne "\033[0;1;44m${*}\033[0m\n"; }
function echo_bold() { echo -ne "\033[0;1;34m${*}\033[0m\n"; }
function echo_danger() { echo -ne "\033[0;31m${*}\033[0m\n"; }
function echo_success() { echo -ne "\033[0;32m${*}\033[0m\n"; }
function echo_warning() { echo -ne "\033[0;33m${*}\033[0m\n"; }
function echo_secondary() { echo -ne "\033[0;34m${*}\033[0m\n"; }
function echo_info() { echo -ne "\033[0;35m${*}\033[0m\n"; }
function echo_primary() { echo -ne "\033[0;36m${*}\033[0m\n"; }
function echo_error() { echo -ne "\033[0;1;31merror:\033[0;31m\t${*}\033[0m\n"; }
function echo_label() { echo -ne "\033[0;1;32m${*}:\033[0m\t"; }
function echo_prompt() { echo -ne "\033[0;36m${*}\033[0m "; }
function splash() {
local hr
hr=" **$(printf "%${#1}s" | tr ' ' '*')** "
echo_title "${hr}"
echo_title " * $1 * "
echo_title "${hr}"
echo
}
function check_root() {
# Checking for root access and proceed if it is present
ROOT_UID=0
if [[ ! "${UID}" -eq "${ROOT_UID}" ]]; then
# Error message
echo_error 'Run me as root.'
echo_info 'try sudo ./install.sh'
exit 1
fi
}
function select_theme() {
themes=('Vimix' 'Cyberpunk' 'Shodan' 'fallout' 'CyberRe' 'Quit')
PS3=$(echo_prompt '\nChoose The Theme You Want: ')
select THEME_NAME in "${themes[@]}"; do
case "${THEME_NAME}" in
'Vimix')
splash 'Installing Vimix Theme'
break;;
'Cyberpunk')
splash 'Installing Cyberpunk Theme'
break;;
'Shodan')
splash 'Installing Shodan Theme'
break;;
'fallout')
splash 'Installing fallout Theme'
break;;
'CyberRe')
splash 'Installing CyberRe Theme'
break;;
'Quit')
echo_info 'User requested exit'
exit 0;;
*) echo_warning "invalid option \"${REPLY}\"";;
esac
done
}
function backup() {
# Backup grub config
echo_info 'cp -an /etc/default/grub /etc/default/grub.bak'
cp -an /etc/default/grub /etc/default/grub.bak
}
function install_theme() {
# create themes directory if not exists
if [[ ! -d "${THEME_DIR}/${THEME_NAME}" ]]; then
# Copy theme
echo_primary "Installing ${THEME_NAME} theme..."
echo_info "mkdir -p \"${THEME_DIR}/${THEME_NAME}\""
mkdir -p "${THEME_DIR}/${THEME_NAME}"
echo_info "cp -a ./themes/\"${THEME_NAME}\"/* \"${THEME_DIR}/${THEME_NAME}\""
cp -a ./themes/"${THEME_NAME}"/* "${THEME_DIR}/${THEME_NAME}"
fi
}
function config_grub() {
echo_primary 'Enabling grub menu'
# remove default grub style if any
echo_info "sed -i '/GRUB_TIMEOUT_STYLE=/d' /etc/default/grub"
sed -i '/GRUB_TIMEOUT_STYLE=/d' /etc/default/grub
echo_info "echo 'GRUB_TIMEOUT_STYLE=\"menu\"' >> /etc/default/grub"
echo 'GRUB_TIMEOUT_STYLE="menu"' >> /etc/default/grub
#--------------------------------------------------
echo_primary 'Setting grub timeout to 10 seconds'
# remove default timeout if any
echo_info "sed -i '/GRUB_TIMEOUT=/d' /etc/default/grub"
sed -i '/GRUB_TIMEOUT=/d' /etc/default/grub
echo_info "echo 'GRUB_TIMEOUT=\"10\"' >> /etc/default/grub"
echo 'GRUB_TIMEOUT="10"' >> /etc/default/grub
#--------------------------------------------------
echo_primary "Setting ${THEME_NAME} as default"
# remove theme if any
echo_info "sed -i '/GRUB_THEME=/d' /etc/default/grub"
sed -i '/GRUB_THEME=/d' /etc/default/grub
echo_info "echo \"GRUB_THEME=\"${THEME_DIR}/${THEME_NAME}/theme.txt\"\" >> /etc/default/grub"
echo "GRUB_THEME=\"${THEME_DIR}/${THEME_NAME}/theme.txt\"" >> /etc/default/grub
#--------------------------------------------------
echo_primary 'Setting grub graphics mode to auto'
# remove default timeout if any
echo_info "sed -i '/GRUB_GFXMODE=/d' /etc/default/grub"
sed -i '/GRUB_GFXMODE=/d' /etc/default/grub
echo_info "echo 'GRUB_GFXMODE=\"auto\"' >> /etc/default/grub"
echo 'GRUB_GFXMODE="auto"' >> /etc/default/grub
}
function update_grub() {
# Update grub config
echo_primary 'Updating grub config...'
if [[ -x "$(command -v update-grub)" ]]; then
echo_info 'update-grub'
update-grub
elif [[ -x "$(command -v grub-mkconfig)" ]]; then
echo_info 'grub-mkconfig -o /boot/grub/grub.cfg'
grub-mkconfig -o /boot/grub/grub.cfg
elif [[ -x "$(command -v grub2-mkconfig)" ]]; then
if [[ -x "$(command -v zypper)" ]]; then
echo_info 'grub2-mkconfig -o /boot/grub2/grub.cfg'
grub2-mkconfig -o /boot/grub2/grub.cfg
elif [[ -x "$(command -v dnf)" ]]; then
echo_info 'grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg'
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
fi
fi
}
function main() {
splash 'Grub2 Theme Installer'
check_root
select_theme
install_theme
config_grub
update_grub
echo_success 'All done !'
}
main