diff --git a/archtitus.sh b/archtitus.sh index 693b248..b9ee60a 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -19,15 +19,17 @@ echo -ne " ------------------------------------------------------------------------- Scripts are in directory named ArchTitus " - ( bash $SCRIPT_DIR/scripts/startup.sh )|& tee startup.log - source $CONFIGS_DIR/setup.conf - ( bash $SCRIPT_DIR/scripts/0-preinstall.sh )|& tee 0-preinstall.log - ( arch-chroot /mnt $HOME/ArchTitus/scripts/1-setup.sh )|& tee 1-setup.log - if [[ ! $DESKTOP_ENV == server ]]; then - ( arch-chroot /mnt /usr/bin/runuser -u $USERNAME -- /home/$USERNAME/ArchTitus/scripts/2-user.sh )|& tee 2-user.log - fi - ( arch-chroot /mnt $HOME/ArchTitus/scripts/3-post-setup.sh )|& tee 3-post-setup.log - cp -v *.log /mnt/home/$USERNAME +mkdir $SCRIPT_DIR/logs +( bash $SCRIPT_DIR/scripts/startup.sh )|& tee $SCRIPT_DIR/logs/startup.log +source $CONFIGS_DIR/setup.conf +( bash $SCRIPT_DIR/scripts/0-preinstall.sh )|& tee $SCRIPT_DIR/logs/0-preinstall.log +( arch-chroot /mnt $HOME/ArchTitus/scripts/1-setup.sh )|& $SCRIPT_DIR/logs/tee 1-setup.log +if [[ ! $DESKTOP_ENV == server ]]; then + ( arch-chroot /mnt /usr/bin/runuser -u $USERNAME -- /home/$USERNAME/ArchTitus/scripts/2-user.sh )|& tee $SCRIPT_DIR/logs/2-user.log +fi +( arch-chroot /mnt $HOME/ArchTitus/scripts/3-post-setup.sh )|& tee $SCRIPT_DIR/logs/3-post-setup.log +mkdir /mnt/home/$USERNAME/installLogs +cp -v $SCRIPT_DIR/logs/*.log /mnt/home/$USERNAME/installLogs echo -ne " ------------------------------------------------------------------------- diff --git a/scripts/0-preinstall.sh b/scripts/0-preinstall.sh index b289307..f774b16 100755 --- a/scripts/0-preinstall.sh +++ b/scripts/0-preinstall.sh @@ -19,7 +19,6 @@ echo -ne " ------------------------------------------------------------------------- Automated Arch Linux Installer ------------------------------------------------------------------------- - Setting up mirrors for optimal download " source $CONFIGS_DIR/setup.conf @@ -155,6 +154,7 @@ echo " Generated /etc/fstab: " cat /mnt/etc/fstab +if [${GRUB_INSTALL} == "yes"]; then echo -ne " ------------------------------------------------------------------------- GRUB BIOS Bootloader Install & Check @@ -165,6 +165,7 @@ if [[ ! -d "/sys/firmware/efi" ]]; then else pacstrap /mnt efibootmgr --noconfirm --needed fi +fi echo -ne " ------------------------------------------------------------------------- Checking for low memory systems <8G @@ -187,4 +188,4 @@ echo -ne " ------------------------------------------------------------------------- SYSTEM READY FOR 1-setup.sh ------------------------------------------------------------------------- -" +" \ No newline at end of file diff --git a/scripts/2-user.sh b/scripts/2-user.sh index b1b2c43..3552984 100755 --- a/scripts/2-user.sh +++ b/scripts/2-user.sh @@ -11,46 +11,45 @@ echo -ne " Automated Arch Linux Installer SCRIPTHOME: ArchTitus ------------------------------------------------------------------------- - Installing AUR Softwares " source $HOME/ArchTitus/configs/setup.conf - cd ~ - mkdir "/home/$USERNAME/.cache" - touch "/home/$USERNAME/.cache/zshhistory" - git clone "https://github.com/ChrisTitusTech/zsh" - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k - ln -s "~/zsh/.zshrc" ~/.zshrc - -sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/${DESKTOP_ENV}.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}" - sudo pacman -S --noconfirm --needed ${line} -done - - -if [[ ! $AUR_HELPER == none ]]; then - cd ~ - git clone "https://aur.archlinux.org/$AUR_HELPER.git" - cd ~/$AUR_HELPER +addAUR () { + 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' ~/ArchTitus/pkg-files/aur-pkgs.txt | while read line + sed -n '/'$INSTALL_TYPE'/q;p' $1 | while read line do - if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then + 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} + sudo pacman -S --noconfirm --needed ${line} done +} + +cd ~ +mkdir "/home/$USERNAME/.cache" +touch "/home/$USERNAME/.cache/zshhistory" +git clone "https://github.com/ChrisTitusTech/zsh" +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k +ln -s "~/zsh/.zshrc" ~/.zshrc + +installFromFile ~/ArchTitus/pkg-files/${DESKTOP_ENV}.txt + +if [[ ! $AUR_HELPER == none ]]; then + addAUR $AUR_HELPER + installFromFile ~/ArchTitus/pkg-files/aur-pkgs.txt fi export PATH=$PATH:~/.local/bin @@ -75,4 +74,4 @@ echo -ne " SYSTEM READY FOR 3-post-setup.sh ------------------------------------------------------------------------- " -exit +exit \ No newline at end of file diff --git a/scripts/3-post-setup.sh b/scripts/3-post-setup.sh index 34c67a0..24e5aa6 100755 --- a/scripts/3-post-setup.sh +++ b/scripts/3-post-setup.sh @@ -11,7 +11,6 @@ echo -ne " Automated Arch Linux Installer SCRIPTHOME: ArchTitus ------------------------------------------------------------------------- - Final Setup and Configurations GRUB EFI Bootloader Install & Check " @@ -33,22 +32,27 @@ fi # set kernel parameter for adding splash screen sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub -echo -e "Installing CyberRe Grub theme..." -THEME_DIR="/boot/grub/themes" -THEME_NAME=CyberRe -echo -e "Creating the theme directory..." -mkdir -p "${THEME_DIR}/${THEME_NAME}" -echo -e "Copying the theme..." -cd ${HOME}/ArchTitus -cp -a configs${THEME_DIR}/${THEME_NAME}/* ${THEME_DIR}/${THEME_NAME} -echo -e "Backing up Grub config..." -cp -an /etc/default/grub /etc/default/grub.bak -echo -e "Setting the theme as the default..." -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 +if [[ ${GRUB_THEME} == "cyberRE" ]]; then + echo -e "Installing CyberRe Grub theme..." + THEME_DIR="/boot/grub/themes" + THEME_NAME=CyberRe + echo -e "Creating the theme directory..." + mkdir -p "${THEME_DIR}/${THEME_NAME}" + echo -e "Copying the theme..." + cd ${HOME}/ArchTitus + cp -a configs${THEME_DIR}/${THEME_NAME}/* ${THEME_DIR}/${THEME_NAME} + echo -e "Backing up Grub config..." + cp -an /etc/default/grub /etc/default/grub.bak + echo -e "Setting the theme as the default..." + 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 + +if [[ ${GRUB_INSTALL} == "Yes" ]]; then echo -e "Updating grub..." grub-mkconfig -o /boot/grub/grub.cfg echo -e "All set!" +fi echo -ne " ------------------------------------------------------------------------- @@ -155,4 +159,4 @@ rm -r $HOME/ArchTitus rm -r /home/$USERNAME/ArchTitus # Replace in the same state -cd $pwd +cd $pwd \ No newline at end of file diff --git a/scripts/startup.sh b/scripts/startup.sh index baf0e75..e7e12ca 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -1,24 +1,25 @@ #!/usr/bin/env bash + # This script will ask users about their prefrences # like disk, file system, timezone, keyboard layout, # user name, password, etc. -# set up a config file +# === set up a config file === CONFIG_FILE=$CONFIGS_DIR/setup.conf if [ ! -f $CONFIG_FILE ]; then # check if file exists touch -f $CONFIG_FILE # create file if not exists fi -# set options in setup.conf +# === set options in setup.conf === set_option() { if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists fi 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 # "opt1" "opt2" ... # Return value: selected index (0 for opt1, 1 for opt2 ...) @@ -125,8 +126,9 @@ select_option() { return $(( $active_col + $active_row * $colmax )) } + +# === This will be shown on every set as user is progressing === logo () { -# This will be shown on every set as user is progressing 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 () { -# This function will handle file systems. At this movement we are handling only -# btrfs and ext4. Others will be added in future. +clear +logo echo -ne " Please Select your file system for both boot and root " @@ -173,8 +178,11 @@ done *) echo "Wrong option please select again"; filesystem;; esac } + +# === Added this from arch wiki https://wiki.archlinux.org/title/System_time === timezone () { -# Added this from arch wiki https://wiki.archlinux.org/title/System_time +clear +logo time_zone="$(curl --fail https://ipapi.co/timezone)" echo -ne " System detected your timezone to be '$time_zone' \n" @@ -195,7 +203,11 @@ case ${options[$?]} in *) echo "Wrong option. Try again";timezone;; esac } + +# === To select the keymap keymap () { +clear +logo echo -ne " Please select key board layout from this list" # 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 } +# === Select if the drive is an ssd or not=== drivessd () { echo -ne " Is this an ssd? yes/no: @@ -225,15 +238,16 @@ case ${options[$?]} in esac } -# selection for disk type +# === selection for disk type === diskpart () { +clear +logo echo -ne " ------------------------------------------------------------------------ THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK Please make sure you know what you are doing because after formating your disk there is no way to get data back ------------------------------------------------------------------------ - " PS3=' @@ -248,15 +262,18 @@ echo -e "\n${disk%|*} selected \n" drivessd } + +# === select userinfo === userinfo () { +clear +logo read -p "Please enter your username: " username set_option USERNAME ${username,,} # convert to lower case as in issue #109 while true; do - echo -ne "Please enter your password: \n" - read -s password # read password without echo - - echo -ne "Please repeat your password: \n" - read -s password2 # read password without echo + read -s -p "Please enter your password: " password # read password without echo + echo "" + read -s -p "Please repeat your password: " password2 # read password without echo + echo "" if [ "$password" = "$password2" ]; then set_option PASSWORD $password @@ -269,8 +286,40 @@ read -rep "Please enter your hostname: " nameofmachine set_option NAME_OF_MACHINE $nameofmachine } +# === install grub or not === +grubInstall () { + echo -ne "Install grub?:\n" + options=("Yes" "No") + select_option $? 1 "${options[@]}" + grub_install=${options[$?]} + set_option GRUB_INSTALL $grub_install +} + +# === select grub theme === +grubTheme () { + echo -ne "Select your grub theme:\n" + options=(cyberRE none) + select_option $? 4 "${options[@]}" + grub_theme=${options[$?]} + set_option GRUB_THEME $grub_theme +} + +# === show all the grub options === +grubOptions () { + clear + logo + grubInstall + if [[ "$grub_install" == "yes" ]]; then + grubTheme + else + set_option GRUB_THEME none + fi +} + +# === Let the user choose AUR helper from predefined list === aurhelper () { - # Let the user choose AUR helper from predefined list + clear + logo echo -ne "Please enter your desired AUR helper:\n" options=(paru yay picaur aura trizen pacaur none) select_option $? 4 "${options[@]}" @@ -278,8 +327,10 @@ aurhelper () { set_option AUR_HELPER $aur_helper } +# === Let the user choose Desktop Enviroment from predefined list === desktopenv () { - # Let the user choose Desktop Enviroment from predefined list + clear + logo echo -ne "Please select your desired Desktop Enviroment:\n" options=(gnome kde cinnamon xfce mate budgie lxde deepin openbox server) select_option $? 4 "${options[@]}" @@ -287,7 +338,10 @@ desktopenv () { set_option DESKTOP_ENV $desktop_env } +# === select installation type === installtype () { + clear + logo 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 Minimal Install: Installs only apps few selected apps to get you started\n" @@ -297,36 +351,24 @@ installtype () { set_option INSTALL_TYPE $install_type } -# More features in future +# === More features in future === # language (){} -# Starting functions -clear -logo +# === setup basic options for server installation === userinfo -clear -logo +grubOptions desktopenv -# Set fixed options that installation uses if user choses server installation + set_option INSTALL_TYPE MINIMAL -set_option AUR_HELPER NONE + +# === configure extra options for DE installation === if [[ ! $desktop_env == server ]]; then - clear - logo - aurhelper - clear - logo +aurhelper installtype fi -clear -logo + +# === more basic options === diskpart -clear -logo filesystem -clear -logo timezone -clear -logo -keymap +keymap \ No newline at end of file