代码拉取完成,页面将自动刷新
#! /usr/bin/env bash
THEME='fallout-grub-theme'
LANG='English'
# Change to temporary directory
cd $(mktemp -d)
# Pre-authorise sudo
sudo echo
# Select language, optional
declare -A LANGS=(
[Chinese]=zh_CN
[English]=EN
[French]=FR
[German]=DE
[Italian]=IT
[Norwegian]=NO
[Portuguese]=PT
[Russian]=RU
[Spanish]=ES
[Ukrainian]=UA
)
LANG_NAMES=($(echo ${!LANGS[*]} | tr ' ' '\n' | sort -n))
PS3='Please select language #: '
select l in "${LANG_NAMES[@]}"
do
if [[ -v LANGS[$l] ]]
then
LANG=$l
break
else
echo 'No such language, try again'
fi
done < /dev/tty
echo 'Fetching theme archive'
wget -O ${THEME}.zip https://github.com/shvchk/${THEME}/archive/master.zip
echo 'Unpacking theme'
unzip ${THEME}.zip
# 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_CFG_PATH='/boot/grub2/grub.cfg'
if [ -d /boot/efi/EFI/${ID} ]
then
GRUB_CFG_PATH="/boot/efi/EFI/${ID}/grub.cfg"
fi
# BLS etries have 'kernel' class, copy corresponding icon
if [[ -d /boot/loader/entries && -e ${THEME}-master/icons/${ID}.png ]]
then
cp ${THEME}-master/icons/${ID}.png ${THEME}-master/icons/kernel.png
fi
GRUB_DIR='grub2'
UPDATE_GRUB="grub2-mkconfig -o ${GRUB_CFG_PATH}"
fi
fi
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
fi
echo 'Creating GRUB themes directory'
sudo mkdir -p /boot/${GRUB_DIR}/themes/${THEME}
echo 'Copying theme to GRUB themes directory'
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
echo 'Making sure GRUB uses graphical output'
sudo sed -i 's/^\(GRUB_TERMINAL\w*=.*\)/#\1/' /etc/default/grub
echo 'Removing empty lines at the end of GRUB config' # optional
sudo sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' /etc/default/grub
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_DIR}/themes/${THEME}/theme.txt" | sudo tee -a /etc/default/grub
echo 'Removing theme installation files'
rm -rf ${THEME}.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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。