2019-11-24 15:17:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Simple app bootstrapping script
|
|
|
|
|
|
|
|
#=== main function ============================================================
|
|
|
|
# NAME: main
|
|
|
|
# DESCRIPTION: Display usage information for this script.
|
|
|
|
# PARAMETERS: see usage function
|
|
|
|
#==============================================================================
|
2020-02-07 21:07:53 +00:00
|
|
|
packages="${BOOTSTRAP_PACKAGES:-packages.txt}"
|
2019-12-30 09:20:17 +00:00
|
|
|
|
2019-11-24 15:17:14 +00:00
|
|
|
main() {
|
2021-04-04 18:52:52 +00:00
|
|
|
local cmd=""
|
|
|
|
local ret=0
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2021-04-04 18:52:52 +00:00
|
|
|
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
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2021-04-04 18:52:52 +00:00
|
|
|
$cmd "$@"
|
|
|
|
ret=$((ret + $?))
|
|
|
|
exit $ret
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_yay() {
|
2021-04-04 18:52:52 +00:00
|
|
|
# check for existing yay installation
|
|
|
|
if type yay >/dev/null 2>&1; then
|
|
|
|
echo "Existing yay installation found ..........................................."
|
|
|
|
return
|
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
|
2021-04-04 18:52:52 +00:00
|
|
|
# use tmp dir to make yay
|
|
|
|
target=$(mktemp -d)
|
|
|
|
git clone https://aur.archlinux.org/yay.git "$target"
|
|
|
|
cd "$target" || exit
|
|
|
|
makepkg -si
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update_repos() {
|
2021-04-04 18:52:52 +00:00
|
|
|
unattended="$1"
|
|
|
|
if "$unattended"; then
|
|
|
|
yay -Sqyy --noconfirm
|
|
|
|
else
|
|
|
|
yay -Syy
|
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_packages() {
|
2021-04-04 18:52:52 +00:00
|
|
|
unattended="$1"
|
|
|
|
if "$unattended"; then
|
|
|
|
yay -Squ --noconfirm --needed - <"$packages"
|
|
|
|
else
|
|
|
|
yay -Su --needed - <"$packages"
|
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_consent() {
|
2021-04-04 18:52:52 +00:00
|
|
|
echo "This will take a while and install many packages. Proceed [y/N]?"
|
|
|
|
read -r yes
|
|
|
|
if [[ "$yes" != y* ]]; then
|
|
|
|
echo "Exiting."
|
|
|
|
exit
|
|
|
|
fi
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
2021-04-04 18:52:52 +00:00
|
|
|
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 ......................................................................"
|
2019-11-24 15:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|