dotfiles/home/bin/executable_linux-update.tmpl
2023-04-03 14:00:04 -07:00

72 lines
1.4 KiB
Bash

#!/usr/bin/env bash
help ()
{
echo "
Update void linux with ansible
Usage: update <tags> <flags>
EXAMPLE TAGS:
packages,configs
FLAGS:
-f, --fedora perform update for fedora
-a, --arch perform update for arch
-v, --void perform update for void
-s, --src compile (or recompile) source based packages"
exit 0
}
POSITIONAL_ARGS=()
SRC=false
while [[ $# -gt 0 ]]; do
case $1 in
-v|--void)
distro="void"
shift
;;
-a|--arch)
distro="arch"
shift
;;
-f|--fedora)
distro="fedora"
shift
;;
-s|--src)
SRC=true
shift
;;
-h|--help)
help
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
# Goto playbook and run it
cd "{{ .chezmoi.workingTree }}/provision/$distro/ansible"
# Install ansible and run playbook
if [ "$SRC" = true ] ; then
echo "Starting update with source packages - be prepated to wait..."
ansible-playbook setup.yml -i hosts --ask-become-pass --tags "$1" --skip-tags "once"
else
echo "Starting update without source packages..."
ansible-playbook setup.yml -i hosts --ask-become-pass --tags "$1" --skip-tags "once,src"
fi
# Return to where you were
cd - > /dev/null