dotfiles/bootstrap/install_packages.sh
Marty Oehme 4634655619 Fix README image paths and dot description
Fixed paths to images for new repository dotfile delineation. Added
quick readme blurb explaining differece of normal and dotfile
directories.
Readme still explained old bare-repository directory structure. Rewrote
sentences to conform to new structure.

Removed underscore from bootstrap directory, since the repository does
not organize itself through underscore prefixes anymore.
Fixed package gathering git-hook to respect new bootstrap directory.
2020-02-11 09:33:18 +00:00

92 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
#
# Simple app bootstrapping script
#=== main function ============================================================
# NAME: main
# DESCRIPTION: Display usage information for this script.
# PARAMETERS: see usage function
#==============================================================================
packages="${BOOTSTRAP_PACKAGES:-packages.txt}"
main() {
local cmd=""
local ret=0
case "$1" in
-v | --version)
printf "Package bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.3\n"
;;
-h | --help)
printf "Usage: install [-f|--force][-v|--version][-h|--help]\n\n-f Do not ask for any confirmations but force update and installation.\n"
;;
-f | --force)
install true
;;
*)
install false
;;
esac
shift
$cmd "$@"
ret=$((ret + $?))
exit $ret
}
install_yay() {
# check for existing yay installation
if type yay >/dev/null 2>&1; then
echo "Existing yay installation found ..........................................."
return
fi
# use tmp dir to make yay
target=$(mktemp -d)
git clone https://aur.archlinux.org/yay.git "$target"
cd "$target" || exit
makepkg -si
}
update_repos() {
unattended="$1"
if "$unattended"; then
yay -Sqyy --noconfirm
else
yay -Syy
fi
}
install_packages() {
unattended="$1"
if "$unattended"; then
yay -Squ --noconfirm --needed - <"$packages"
else
yay -Su --needed - <"$packages"
fi
}
check_consent() {
echo "This will take a while and install many packages. Proceed [y/N]?"
read -r yes
if [[ "$yes" != y* ]]; then
echo "Exiting."
exit
fi
}
install() {
unattended=$1
echo "Beginning package bootstrap ..............................................."
if ! "$unattended"; then
check_consent
fi
echo "Installing yay ............................................................"
install_yay
echo "Installing apps ..........................................................."
update_repos "$unattended"
install_packages "$unattended"
echo "Done ......................................................................"
}
main "$@"