diff --git a/install b/install index 22cb04f..d508557 100755 --- a/install +++ b/install @@ -19,8 +19,6 @@ ############################################################################### # Configuration variables # ############################################################################### -set -e - HOST="$(hostname)" # Directories which should be created @@ -178,16 +176,13 @@ COPY_ROOT_FILES=( echo "${BOLD}Before you continue with this script make sure that:" echo " • The user severin is added to the sudoers file" echo " • The multilib repository is uncommented in /etc/pacman.conf" -echo -e " • Your SSH keys are located in ~/.ssh${RESET}" +echo -e " • Your SSH keys are located in ~/.ssh${RESET}\n" -read -p "Are you ready to continue? (y/n): " -n 1 -r -echo "" - -if [[ $REPLY =~ ^[nN]$ ]] -then - exit +if ! ask_prompt "Are you ready to continue?"; then + exit 1 fi + ############################################################################### # Work specific settings # ############################################################################### @@ -217,39 +212,50 @@ fi # print_log "yay is already installed" # fi -print_section "Installing native packages" # List created using: yay -Qqen > packages.native.list package_count=$(< "${PACKAGES_DIR}/packages.native.list" wc -l) -print_log "Installing ${package_count} packages" -yay -Syy > /dev/null 2>&1 -yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.native.list" -# print_section "Installing Rust toolchain and components" -# rustup toolchain install beta -# rustup default beta -# rustup component add "${RUST_COMPONENTS[@]}" -# rustup default beta +if ask_prompt "Do you want to install ${package_count} Arch packages?"; then + print_log "Installing ${package_count} Arch packages" + yay -Syy > /dev/null 2>&1 + yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.native.list" +fi + + +if ask_prompt "Do you want to install a rust toolchain?"; then + rustup toolchain install beta + rustup default beta + rustup component add "${RUST_COMPONENTS[@]}" + rustup default beta +fi + -print_section "Installing AUR packages" -package_count=$(< "${PACKAGES_DIR}/packages.aur.list" wc -l) # List created using: yay -Qqem > packages.aur.list -print_log "Installing ${package_count} packages" -yay -Syy > /dev/null 2>&1 -yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.aur.list" +package_count=$(< "${PACKAGES_DIR}/packages.aur.list" wc -l) +if ask_prompt "Do you want to install ${package_count} AUR packages?"; then + print_log "Installing ${package_count} AUR packages" + yay -Syy > /dev/null 2>&1 + yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.aur.list" +fi + +# Remove unneeded packages #yay -Rsu $(comm -23 <(pacman -Qq | sort) <(cat "${PACKAGES_DIR}/packages.native.list" "${PACKAGES_DIR}/packages.aur.list" | sort)) -#print_section "Installing global npm packages" -#print_log "Installing ${#NPM_PACKAGES[@]} packages" -#npm i -g "${NPM_PACKAGES[@]}" -# -#print_section "Installing global composer packages" -#print_log "Installing ${#COMPOSER_PACKAGES[@]} packages" -#composer global require "${COMPOSER_PACKAGES[@]}" -# -#print_section "Installing ruby gems" -#print_log "Installing ${#RUBY_GEMS[@]} packages" -#gem install "${RUBY_GEMS[@]}" +if ask_prompt "Do you want to install ${#NPM_PACKAGES[@]} global npm packages?"; then + print_log "Installing ${#NPM_PACKAGES[@]} packages" + npm i -g "${NPM_PACKAGES[@]}" +fi + +if ask_prompt "Do you want to install ${#COMPOSER_PACKAGES[@]} global composer packages?"; then + print_log "Installing ${#COMPOSER_PACKAGES[@]} packages" + composer global require "${COMPOSER_PACKAGES[@]}" +fi + +if ask_prompt "Do you want to install ${#RUBY_GEMS[@]} ruby gems?"; then + print_log "Installing ${#RUBY_GEMS[@]} gems" + gem install "${RUBY_GEMS[@]}" +fi ############################################################################### # Creating directories # diff --git a/system/.local/bin/utils b/system/.local/bin/utils index b201703..22c5411 100755 --- a/system/.local/bin/utils +++ b/system/.local/bin/utils @@ -28,6 +28,7 @@ RED='\033[31m' BLUE='\033[34m' YELLOW='\033[33m' BOLD="$(tput bold)" +NORMAL="$(tput sgr0)" ####################################### # Helper functions @@ -56,4 +57,15 @@ function print_section() { function print_log() { echo -e " • $1" +} + +function ask_prompt() { + read -p "${BOLD}${1} (y/n): ${NORMAL}" -n 1 -r + echo "" + + if [[ ${REPLY} =~ ^[^yY]$ ]]; then + return 1 + fi + + return 0 } \ No newline at end of file