Add distro detection to use distro-specific GRUB location and update method
This commit is contained in:
57
install.sh
57
install.sh
@@ -32,9 +32,35 @@ do
|
||||
fi
|
||||
done < /dev/tty
|
||||
|
||||
# Detect distro and set GRUB location and update method
|
||||
GRUB_DIR='grub'
|
||||
UPDATE_GRUB=''
|
||||
|
||||
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
|
||||
|
||||
GRUB_DIR='grub2'
|
||||
UPDATE_GRUB='grub2-mkconfig -o /boot/grub2/grub.cfg'
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo 'Fetching theme archive'
|
||||
wget https://github.com/shvchk/$THEME/archive/master.zip
|
||||
wget https://github.com/shvchk/${THEME}/archive/master.zip
|
||||
|
||||
echo 'Unpacking theme'
|
||||
unzip master.zip
|
||||
@@ -43,14 +69,14 @@ if [[ "$LANG" != "English" ]]
|
||||
then
|
||||
echo "Changing language to ${LANG}"
|
||||
sed -i -r -e '/^\s+# EN$/{n;s/^(\s*)/\1# /}' \
|
||||
-e '/^\s+# '"${LANGS[$LANG]}"'$/{n;s/^(\s*)#\s*/\1/}' $THEME-master/theme.txt
|
||||
-e '/^\s+# '"${LANGS[$LANG]}"'$/{n;s/^(\s*)#\s*/\1/}' ${THEME}-master/theme.txt
|
||||
fi
|
||||
|
||||
echo 'Creating GRUB themes directory'
|
||||
sudo mkdir -p /boot/grub/themes/$THEME
|
||||
sudo mkdir -p /boot/${GRUB_DIR}/themes/${THEME}
|
||||
|
||||
echo 'Copying theme to GRUB themes directory'
|
||||
sudo cp -r $THEME-master/* /boot/grub/themes/$THEME
|
||||
sudo cp -r ${THEME}-master/* /boot/${GRUB_DIR}/themes/${THEME}
|
||||
|
||||
echo 'Removing other themes from GRUB config'
|
||||
sudo sed -i '/^GRUB_THEME=/d' /etc/default/grub
|
||||
@@ -62,10 +88,23 @@ echo 'Adding new line to GRUB config just in case' # optional
|
||||
echo | sudo tee -a /etc/default/grub
|
||||
|
||||
echo 'Adding theme to GRUB config'
|
||||
echo "GRUB_THEME=/boot/grub/themes/$THEME/theme.txt" | sudo tee -a /etc/default/grub
|
||||
|
||||
echo 'Updating GRUB'
|
||||
sudo update-grub
|
||||
echo "GRUB_THEME=/boot/${GRUB_DIR}/themes/${THEME}/theme.txt" | sudo tee -a /etc/default/grub
|
||||
|
||||
echo 'Removing theme installation files'
|
||||
rm -rf master.zip $THEME-master
|
||||
rm -rf master.zip ${THEME}-master
|
||||
|
||||
echo 'Updating GRUB'
|
||||
if [[ $UPDATE_GRUB ]]; then
|
||||
eval sudo "$UPDATE_GRUB"
|
||||
else
|
||||
cat << ' EOF'
|
||||
--------------------------------------------------------------------------------
|
||||
Cannot detect your distro, you will need to run `grub-mkconfig` (as root) manually.
|
||||
|
||||
Common ways:
|
||||
- Debian, Ubuntu, Solus and derivatives: `update-grub` or `grub-mkconfig -o /boot/grub/grub.cfg`
|
||||
- RHEL, CentOS, Fedora, SUSE and derivatives: `grub2-mkconfig -o /boot/grub2/grub.cfg`
|
||||
- Arch, Gentoo and derivatives: `grub-mkconfig -o /boot/grub/grub.cfg`
|
||||
--------------------------------------------------------------------------------
|
||||
EOF
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user