-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·50 lines (41 loc) · 1.31 KB
/
setup.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
#!/bin/bash
grub="/etc/default/grub"
grubThemes="/usr/share/grub/themes"
theme="ant"
function createGrub() {
if [[ ! -d $grubThemes ]]; then sudo mkdir $grubThemes; fi
if [[ ! -d $grubThemes/$theme ]]; then
sudo mkdir $grubThemes/$theme
sudo cp $grub $grub.bak
sudo cp -r * $grubThemes/$theme
fi
}
function editGrub() {
sudo sed -i '/GRUB_TIMEOUT_STYLE=/d' $grub
sudo sed -i '/GRUB_TIMEOUT=/d' $grub
sudo sed -i '/GRUB_THEME=/d' $grub
sudo bash -c "echo 'GRUB_TIMEOUT_STYLE=\"menu\"' >> $grub"
sudo bash -c "echo 'GRUB_TIMEOUT=\"6\"' >> $grub"
sudo bash -c "echo 'GRUB_THEME=\"$grubThemes/$theme/theme.txt\"' >> $grub"
}
function updateGrub() {
if [[ -x "$(command -v update-grub)" ]]; then
sudo update-grub
elif [[ -x "$(command -v grub-mkconfig)" ]]; then
sudo grub-mkconfig -o /boot/grub/grub.cfg
elif [[ -x "$(command -v grub2-mkconfig)" ]]; then
if [[ -x "$(command -v zypper)" ]]; then
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
elif [[ -x "$(command -v dnf)" ]]; then
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
fi
fi
}
if [[ $# -eq 0 ]]; then
createGrub
editGrub
elif [[ $1 == "-r" ]]; then
sudo rm -r $grubThemes/$theme
sudo cp $grub $grub.bak
fi
updateGrub