diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/apt-up | 53 | 
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/apt-up b/scripts/apt-up new file mode 100755 index 0000000..e380b51 --- /dev/null +++ b/scripts/apt-up @@ -0,0 +1,53 @@ +#!/usr/bin/env	bash + +upgrade_options='' +ARGS=$(getopt -a -o hy --long opts:,help -- "$@") + +update_database() { +    echo 'Updating database...' +    apt update +} + +upgrade_packages() { +    echo 'Upgrading packages...' +    apt upgrade $upgrade_options +} + +help_page() { +    echo "Usage:" +    echo "apt-up [-y] [-h] [--opts $upgrade_options]" +    echo "Description:" +    echo -e "\t-y automates the upgrade progress." +    echo -e "\t-h diaplays the help page of apt-up." +    echo -e '\t--opts transports $upgrade_options to apt.' +    exit -1 +} + +update() { +    update_database +    upgrade_packages +    exit 0 +} + +eval set -- "${ARGS}" + +while :; do +    case $1 in +    -y | --yes) +        upgrade_options+='-y ' +        update +        ;; +    -h | --help) +        help_page +        ;; +    *) +        update +        ;; +    --opts) +        upgrade_options+=$2 +        update +        shift +        ;; +    esac +    shift +done  | 
