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

66
install
View file

@ -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"
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 Rust toolchain and components"
# rustup toolchain install beta
# rustup default beta
# rustup component add "${RUST_COMPONENTS[@]}"
# rustup default beta
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"
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 #

View file

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