Update install.sh

This commit is contained in:
Vince 2022-01-22 18:29:10 +08:00
parent 468bee78f5
commit 9e440c4bbc

View File

@ -1,34 +1,8 @@
#! /usr/bin/env bash #! /usr/bin/env bash
# Exit Immediately if a command fails # Exit Immediately if a command fails
set -o errexit set -o errexit
#
# ──────────────────────────────────────────────────── I ──────────
# :::::: C O L O R S : : : : : : : :
# ──────────────────────────────────────────────────────────────
#
CDEF=" \033[0m" # default color
CCIN=" \033[0;36m" # info color
CGSC=" \033[0;32m" # success color
CRER=" \033[0;31m" # error color
CWAR=" \033[0;33m" # waring color
b_CDEF=" \033[1;37m" # bold default color
b_CCIN=" \033[1;36m" # bold info color
b_CGSC=" \033[1;32m" # bold success color
b_CRER=" \033[1;31m" # bold error color
b_CWAR=" \033[1;33m" # bold warning color
#
# ────────────────────────────────────────────────────── II ──────────
# :::::: G L O B A L S : : : : : : : :
# ────────────────────────────────────────────────────────────────
#
readonly ROOT_UID=0 readonly ROOT_UID=0
readonly Project_Name="GRUB2::THEMES" readonly Project_Name="GRUB2::THEMES"
readonly MAX_DELAY=20 # max delay for user to enter root password readonly MAX_DELAY=20 # max delay for user to enter root password
@ -41,12 +15,24 @@ THEME_VARIANTS=('tela' 'vimix' 'stylish' 'whitesur')
ICON_VARIANTS=('color' 'white' 'whitesur') ICON_VARIANTS=('color' 'white' 'whitesur')
SCREEN_VARIANTS=('1080p' '2k' '4k' 'ultrawide' 'ultrawide2k') SCREEN_VARIANTS=('1080p' '2k' '4k' 'ultrawide' 'ultrawide2k')
#################################
# :::::: C O L O R S :::::: #
#################################
# CDEF=" \033[0m" # default color
# ────────────────────────────────────────────────────────── III ────────── CCIN=" \033[0;36m" # info color
# :::::: F U N C T I O N S : : : : : : : : CGSC=" \033[0;32m" # success color
# ──────────────────────────────────────────────────────────────────── CRER=" \033[0;31m" # error color
# CWAR=" \033[0;33m" # waring color
b_CDEF=" \033[1;37m" # bold default color
b_CCIN=" \033[1;36m" # bold info color
b_CGSC=" \033[1;32m" # bold success color
b_CRER=" \033[1;31m" # bold error color
b_CWAR=" \033[1;33m" # bold warning color
#######################################
# :::::: F U N C T I O N S :::::: #
#######################################
# echo like ... with flag type and display message colors # echo like ... with flag type and display message colors
prompt () { prompt () {
@ -201,22 +187,17 @@ install() {
# Update grub config # Update grub config
prompt -s "\n Updating grub config...\n" prompt -s "\n Updating grub config...\n"
updating_grub updating_grub
prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' " prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' "
#Check if password is cached (if cache timestamp has not expired yet) #Check if password is cached (if cache timestamp has not expired yet)
elif sudo -n true 2> /dev/null && echo; then #No need for "$?" ==> https://github.com/koalaman/shellcheck/wiki/SC2181 elif sudo -n true 2> /dev/null && echo; then #No need for "$?" ==> https://github.com/koalaman/shellcheck/wiki/SC2181
sudo "$0" -t ${theme} -i ${icon} -s ${screen} sudo "$0" -t ${theme} -i ${icon} -s ${screen}
else else
#Ask for password #Ask for password
if [[ -n ${tui_root_login} ]] ; then if [[ -n ${tui_root_login} ]] ; then
if [[ -n "${theme}" && -n "${screen}" ]]; then if [[ -n "${theme}" && -n "${screen}" ]]; then
sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login} sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login}
fi fi
else else
@ -340,21 +321,15 @@ updating_grub() {
} }
function install_program () { function install_program () {
if has_command zypper; then if has_command zypper; then
zypper in "$@" zypper in "$@"
elif has_command apt-get; then elif has_command apt-get; then
apt-get install "$@" apt-get install "$@"
elif has_command dnf; then elif has_command dnf; then
dnf install -y "$@" dnf install -y "$@"
elif has_command yum; then elif has_command yum; then
yum install "$@" yum install "$@"
elif has_command pacman; then elif has_command pacman; then
pacman -S --noconfirm "$@" pacman -S --noconfirm "$@"
fi fi
} }
@ -466,12 +441,9 @@ dialog_installer() {
install "${theme}" "${icon}" "${screen}" install "${theme}" "${icon}" "${screen}"
} }
#######################################################
# # :::::: A R G U M E N T H A N D L I N G :::::: #
# ────────────────────────────────────────────────────────────────────────── IV ────────── #######################################################
# :::::: A R G U M E N T H A N D L I N G : : : : : : : :
# ────────────────────────────────────────────────────────────────────────────────────
#
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
PROG_ARGS+=("${1}") PROG_ARGS+=("${1}")
@ -590,12 +562,9 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
#############################
# # :::::: M A I N :::::: #
# ──────────────────────────────────────────────── V ────────── #############################
# :::::: M A I N : : : : : : : :
# ──────────────────────────────────────────────────────────
#
# Show terminal user interface for better use # Show terminal user interface for better use
if [[ "${dialog:-}" == 'false' ]]; then if [[ "${dialog:-}" == 'false' ]]; then