diff --git a/.bash_completion.d/update b/.bash_completion.d/update new file mode 100644 index 0000000000000000000000000000000000000000..0b89c97baed30aec0ff2f63665b54f7f0cba2fce --- /dev/null +++ b/.bash_completion.d/update @@ -0,0 +1,15 @@ +# vim: ft=bash + +_update() { + local cur prev words cword opts + _init_completion || return + opts='-h -d' + if [[ $cur == -* ]] + then + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + else + COMPREPLY=($(compgen -W "all apt flatpak workbench" -- "$cur")) + fi +} + +complete -F _update update diff --git a/Documents/bin/apt-daily b/Documents/bin/apt-daily deleted file mode 100755 index 65258e080e0f4ceca66e840e4e98994b205ec0fb..0000000000000000000000000000000000000000 --- a/Documents/bin/apt-daily +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --download-only --yes && apt-get autoclean' diff --git a/Documents/bin/flatpak-daily b/Documents/bin/flatpak-daily deleted file mode 100755 index bf88308fb0820b6719af4a0c3aa771332561954f..0000000000000000000000000000000000000000 --- a/Documents/bin/flatpak-daily +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -flatpak --system update --appstream -flatpak --system update --assumeyes -flatpak --system uninstall --unused --assumeyes diff --git a/Documents/bin/update b/Documents/bin/update new file mode 100755 index 0000000000000000000000000000000000000000..62bb92a87f5a838931cbbf75bb52354c4955d4d9 --- /dev/null +++ b/Documents/bin/update @@ -0,0 +1,77 @@ +#!/bin/sh +set -eu + +usage () { + echo "Usage: $0 [-d] [all|apt|flatpak|workbench]" +} + +header () { + printf '\n\e[1;92m=== %s ====\e[0m\n\n' "$*" >&2 +} + +_apt () { + header Updating APT + if [ -n "${DOWNLOAD_ONLY:-}" ] + then + sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --download-only --yes && apt-get autoclean' + else + sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --yes --auto-remove --purge && apt-get autoclean' + fi +} + +_flatpak() { + header Updating Flatpak + flatpak --system update --appstream + + if [ -n "${DOWNLOAD_ONLY:-}" ] + then + flatpak --system update --assumeyes --no-deploy + else + flatpak --system update --assumeyes + flatpak --system uninstall --unused --assumeyes + fi +} + +_workbench() { + header Updating Workbench + if [ -n "${DOWNLOAD_ONLY:-}" ] + then + wb --dry-update + else + wb --update + fi +} + +_all() { + _apt + _flatpak + _workbench +} + +while getopts 'dh' opt +do + case "$opt" in + d) DOWNLOAD_ONLY=1;; + h) usage;; + *) usage; exit 1;; + esac +done + +shift "$(( OPTIND - 1 ))" + +if [ "$#" -eq 0 ] +then + _all +elif [ "$#" -gt 1 ] +then + usage + exit 1 +else + case "$1" in + all) _all;; + apt) _apt;; + flatpak) _flatpak;; + workbench|wb) _workbench;; + *) usage; exit 1;; + esac +fi