cleanup code + add option to select grub theme

This commit is contained in:
godalming123 2022-02-27 09:45:10 +00:00 committed by GitHub
parent 8fb6610ee9
commit 104e37312c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 76 deletions

View File

@ -14,6 +14,31 @@ echo -ne "
Installing AUR Softwares Installing AUR Softwares
" "
addAUR () {
cd ~
git clone "https://aur.archlinux.org/$1.git"
cd ~/$1
makepkg -si --noconfirm
cd ~
rm -r ~/$1
}
installFromFile () {
# sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop
# stop the script and move on, not installing any more packages below that line
sed -n '/'$INSTALL_TYPE'/q;p' $1 | while read line
do
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]
then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue
fi
echo "INSTALLING: ${line}"
sudo pacman -S --noconfirm --needed ${line}
done
}
source $HOME/ArchTitus/configs/setup.conf source $HOME/ArchTitus/configs/setup.conf
cd ~ cd ~
@ -23,34 +48,11 @@ source $HOME/ArchTitus/configs/setup.conf
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
ln -s "~/zsh/.zshrc" ~/.zshrc ln -s "~/zsh/.zshrc" ~/.zshrc
sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/${DESKTOP_ENV}.txt | while read line installFromFile ~/ArchTitus/pkg-files/${DESKTOP_ENV}.txt
do
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]
then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue
fi
echo "INSTALLING: ${line}"
sudo pacman -S --noconfirm --needed ${line}
done
if [[ ! $AUR_HELPER == none ]]; then if [[ ! $AUR_HELPER == none ]]; then
cd ~ addAUR $AUR_HELPER
git clone "https://aur.archlinux.org/$AUR_HELPER.git" installFromFile ~/ArchTitus/pkg-files/aur-pkgs.txt
cd ~/$AUR_HELPER
makepkg -si --noconfirm
# sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop
# stop the script and move on, not installing any more packages below that line
sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/aur-pkgs.txt | while read line
do
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue
fi
echo "INSTALLING: ${line}"
$AUR_HELPER -S --noconfirm --needed ${line}
done
fi fi
export PATH=$PATH:~/.local/bin export PATH=$PATH:~/.local/bin

View File

@ -34,18 +34,21 @@ fi
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub
echo -e "Installing CyberRe Grub theme..." echo -e "Installing CyberRe Grub theme..."
THEME_DIR="/boot/grub/themes" if [ "$GRUB_THEME" == "cyberRE"]; then
THEME_NAME=CyberRe THEME_DIR="/boot/grub/themes"
echo -e "Creating the theme directory..." THEME_NAME=CyberRe
mkdir -p "${THEME_DIR}/${THEME_NAME}" echo -e "Creating the theme directory..."
echo -e "Copying the theme..." mkdir -p "${THEME_DIR}/${THEME_NAME}"
cd ${HOME}/ArchTitus echo -e "Copying the theme..."
cp -a configs${THEME_DIR}/${THEME_NAME}/* ${THEME_DIR}/${THEME_NAME} cd ${HOME}/ArchTitus
echo -e "Backing up Grub config..." cp -a configs${THEME_DIR}/${THEME_NAME}/* ${THEME_DIR}/${THEME_NAME}
cp -an /etc/default/grub /etc/default/grub.bak echo -e "Backing up Grub config..."
echo -e "Setting the theme as the default..." cp -an /etc/default/grub /etc/default/grub.bak
grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_THEME=/d' /etc/default/grub echo -e "Setting the theme as the default..."
echo "GRUB_THEME=\"${THEME_DIR}/${THEME_NAME}/theme.txt\"" >> /etc/default/grub grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_THEME=/d' /etc/default/grub
echo "GRUB_THEME=\"${THEME_DIR}/${THEME_NAME}/theme.txt\"" >> /etc/default/grub
fi
echo -e "Updating grub..." echo -e "Updating grub..."
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg
echo -e "All set!" echo -e "All set!"

View File

@ -1,24 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This script will ask users about their prefrences # This script will ask users about their prefrences
# like disk, file system, timezone, keyboard layout, # like disk, file system, timezone, keyboard layout,
# user name, password, etc. # user name, password, etc.
# set up a config file # === set up a config file ===
CONFIG_FILE=$CONFIGS_DIR/setup.conf CONFIG_FILE=$CONFIGS_DIR/setup.conf
if [ ! -f $CONFIG_FILE ]; then # check if file exists if [ ! -f $CONFIG_FILE ]; then # check if file exists
touch -f $CONFIG_FILE # create file if not exists touch -f $CONFIG_FILE # create file if not exists
fi fi
# set options in setup.conf # === set options in setup.conf ===
set_option() { set_option() {
if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists
sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists
fi fi
echo "${1}=${2}" >>$CONFIG_FILE # add option echo "${1}=${2}" >>$CONFIG_FILE # add option
} }
# Renders a text based list of options that can be selected by the
# user using up, down and enter keys and returns the chosen option. # === Renders a text based list of options that can be selected by the ===
# # === user using up, down and enter keys and returns the chosen option. ===
# Arguments : list of options, maximum of 256 # Arguments : list of options, maximum of 256
# "opt1" "opt2" ... # "opt1" "opt2" ...
# Return value: selected index (0 for opt1, 1 for opt2 ...) # Return value: selected index (0 for opt1, 1 for opt2 ...)
@ -125,8 +126,9 @@ select_option() {
return $(( $active_col + $active_row * $colmax )) return $(( $active_col + $active_row * $colmax ))
} }
# === This will be shown on every set as user is progressing ===
logo () { logo () {
# This will be shown on every set as user is progressing
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
█████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗
@ -140,9 +142,12 @@ echo -ne "
------------------------------------------------------------------------ ------------------------------------------------------------------------
" "
} }
# === This function will handle file systems. At this movement we are handling only ===
# === btrfs and ext4. Others will be added in future. ===
filesystem () { filesystem () {
# This function will handle file systems. At this movement we are handling only clear
# btrfs and ext4. Others will be added in future. logo
echo -ne " echo -ne "
Please Select your file system for both boot and root Please Select your file system for both boot and root
" "
@ -173,8 +178,11 @@ done
*) echo "Wrong option please select again"; filesystem;; *) echo "Wrong option please select again"; filesystem;;
esac esac
} }
# === Added this from arch wiki https://wiki.archlinux.org/title/System_time ===
timezone () { timezone () {
# Added this from arch wiki https://wiki.archlinux.org/title/System_time clear
logo
time_zone="$(curl --fail https://ipapi.co/timezone)" time_zone="$(curl --fail https://ipapi.co/timezone)"
echo -ne " echo -ne "
System detected your timezone to be '$time_zone' \n" System detected your timezone to be '$time_zone' \n"
@ -195,7 +203,11 @@ case ${options[$?]} in
*) echo "Wrong option. Try again";timezone;; *) echo "Wrong option. Try again";timezone;;
esac esac
} }
# === To select the keymap
keymap () { keymap () {
clear
logo
echo -ne " echo -ne "
Please select key board layout from this list" Please select key board layout from this list"
# These are default key maps as presented in official arch repo archinstall # These are default key maps as presented in official arch repo archinstall
@ -208,6 +220,7 @@ echo -ne "Your key boards layout: ${keymap} \n"
set_option KEYMAP $keymap set_option KEYMAP $keymap
} }
# === Select if the drive is an ssd or not===
drivessd () { drivessd () {
echo -ne " echo -ne "
Is this an ssd? yes/no: Is this an ssd? yes/no:
@ -225,8 +238,10 @@ case ${options[$?]} in
esac esac
} }
# selection for disk type # === selection for disk type ===
diskpart () { diskpart () {
clear
logo
echo -ne " echo -ne "
------------------------------------------------------------------------ ------------------------------------------------------------------------
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
@ -248,15 +263,18 @@ echo -e "\n${disk%|*} selected \n"
drivessd drivessd
} }
# === select userinfo ===
userinfo () { userinfo () {
clear
logo
read -p "Please enter your username: " username read -p "Please enter your username: " username
set_option USERNAME ${username,,} # convert to lower case as in issue #109 set_option USERNAME ${username,,} # convert to lower case as in issue #109
while true; do while true; do
echo -ne "Please enter your password: \n" read -s -p "Please enter your password: " password # read password without echo
read -s password # read password without echo echo ""
read -s -p "Please repeat your password: " password2 # read password without echo
echo -ne "Please repeat your password: \n" echo ""
read -s password2 # read password without echo
if [ "$password" = "$password2" ]; then if [ "$password" = "$password2" ]; then
set_option PASSWORD $password set_option PASSWORD $password
@ -269,8 +287,21 @@ read -rep "Please enter your hostname: " nameofmachine
set_option NAME_OF_MACHINE $nameofmachine set_option NAME_OF_MACHINE $nameofmachine
} }
# === select grub theme ===
grubTheme () {
clear
logo
echo -ne "Select your grub theme:\n"
options=(cyberRE none)
select_option $? 4 "${options[@]}"
grub_theme=${options[$?]}
set_option GRUB_THEME $grub_theme
}
# === Let the user choose AUR helper from predefined list ===
aurhelper () { aurhelper () {
# Let the user choose AUR helper from predefined list clear
logo
echo -ne "Please enter your desired AUR helper:\n" echo -ne "Please enter your desired AUR helper:\n"
options=(paru yay picaur aura trizen pacaur none) options=(paru yay picaur aura trizen pacaur none)
select_option $? 4 "${options[@]}" select_option $? 4 "${options[@]}"
@ -278,8 +309,10 @@ aurhelper () {
set_option AUR_HELPER $aur_helper set_option AUR_HELPER $aur_helper
} }
# === Let the user choose Desktop Enviroment from predefined list ===
desktopenv () { desktopenv () {
# Let the user choose Desktop Enviroment from predefined list clear
logo
echo -ne "Please select your desired Desktop Enviroment:\n" echo -ne "Please select your desired Desktop Enviroment:\n"
options=(gnome kde cinnamon xfce mate budgie lxde deepin openbox server) options=(gnome kde cinnamon xfce mate budgie lxde deepin openbox server)
select_option $? 4 "${options[@]}" select_option $? 4 "${options[@]}"
@ -287,7 +320,10 @@ desktopenv () {
set_option DESKTOP_ENV $desktop_env set_option DESKTOP_ENV $desktop_env
} }
# === select installation type ===
installtype () { installtype () {
clear
logo
echo -ne "Please select type of installation:\n\n echo -ne "Please select type of installation:\n\n
Full install: Installs full featured desktop enviroment, with added apps and themes needed for everyday use\n Full install: Installs full featured desktop enviroment, with added apps and themes needed for everyday use\n
Minimal Install: Installs only apps few selected apps to get you started\n" Minimal Install: Installs only apps few selected apps to get you started\n"
@ -297,36 +333,24 @@ installtype () {
set_option INSTALL_TYPE $install_type set_option INSTALL_TYPE $install_type
} }
# More features in future # === More features in future ===
# language (){} # language (){}
# Starting functions # === setup basic options for server installation ===
clear
logo
userinfo userinfo
clear grub_theme
logo aurhelper
desktopenv desktopenv
# Set fixed options that installation uses if user choses server installation
set_option INSTALL_TYPE MINIMAL set_option INSTALL_TYPE MINIMAL
set_option AUR_HELPER NONE
# === configure extra options for DE installation ===
if [[ ! $desktop_env == server ]]; then if [[ ! $desktop_env == server ]]; then
clear
logo
aurhelper
clear
logo
installtype installtype
fi fi
clear
logo # === more basic options ===
diskpart diskpart
clear
logo
filesystem filesystem
clear
logo
timezone timezone
clear
logo
keymap keymap