Ask for confirmation in install script

Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
Severin Kaderli 2019-09-10 18:55:59 +02:00
parent 5c401ac0f6
commit 1c7b6a328a
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4
2 changed files with 52 additions and 34 deletions

74
install
View file

@ -19,8 +19,6 @@
############################################################################### ###############################################################################
# Configuration variables # # Configuration variables #
############################################################################### ###############################################################################
set -e
HOST="$(hostname)" HOST="$(hostname)"
# Directories which should be created # Directories which should be created
@ -178,16 +176,13 @@ COPY_ROOT_FILES=(
echo "${BOLD}Before you continue with this script make sure that:" echo "${BOLD}Before you continue with this script make sure that:"
echo " • The user severin is added to the sudoers file" echo " • The user severin is added to the sudoers file"
echo " • The multilib repository is uncommented in /etc/pacman.conf" 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 if ! ask_prompt "Are you ready to continue?"; then
echo "" exit 1
if [[ $REPLY =~ ^[nN]$ ]]
then
exit
fi fi
############################################################################### ###############################################################################
# Work specific settings # # Work specific settings #
############################################################################### ###############################################################################
@ -217,39 +212,50 @@ fi
# print_log "yay is already installed" # print_log "yay is already installed"
# fi # fi
print_section "Installing native packages"
# List created using: yay -Qqen > packages.native.list # List created using: yay -Qqen > packages.native.list
package_count=$(< "${PACKAGES_DIR}/packages.native.list" wc -l) 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" if ask_prompt "Do you want to install ${package_count} Arch packages?"; then
# rustup toolchain install beta print_log "Installing ${package_count} Arch packages"
# rustup default beta yay -Syy > /dev/null 2>&1
# rustup component add "${RUST_COMPONENTS[@]}" yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.native.list"
# rustup default beta 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 # List created using: yay -Qqem > packages.aur.list
print_log "Installing ${package_count} packages" package_count=$(< "${PACKAGES_DIR}/packages.aur.list" wc -l)
yay -Syy > /dev/null 2>&1
yay -S --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.aur.list"
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)) #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" if ask_prompt "Do you want to install ${#NPM_PACKAGES[@]} global npm packages?"; then
#print_log "Installing ${#NPM_PACKAGES[@]} packages" print_log "Installing ${#NPM_PACKAGES[@]} packages"
#npm i -g "${NPM_PACKAGES[@]}" npm i -g "${NPM_PACKAGES[@]}"
# fi
#print_section "Installing global composer packages"
#print_log "Installing ${#COMPOSER_PACKAGES[@]} packages" if ask_prompt "Do you want to install ${#COMPOSER_PACKAGES[@]} global composer packages?"; then
#composer global require "${COMPOSER_PACKAGES[@]}" print_log "Installing ${#COMPOSER_PACKAGES[@]} packages"
# composer global require "${COMPOSER_PACKAGES[@]}"
#print_section "Installing ruby gems" fi
#print_log "Installing ${#RUBY_GEMS[@]} packages"
#gem install "${RUBY_GEMS[@]}" 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 # # Creating directories #

View file

@ -28,6 +28,7 @@ RED='\033[31m'
BLUE='\033[34m' BLUE='\033[34m'
YELLOW='\033[33m' YELLOW='\033[33m'
BOLD="$(tput bold)" BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
####################################### #######################################
# Helper functions # Helper functions
@ -57,3 +58,14 @@ function print_section() {
function print_log() { function print_log() {
echo -e " • $1" 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
}