summaryrefslogtreecommitdiffstats
path: root/dot_local/bin
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2024-11-11 11:55:47 -0600
committerMatt Strapp <matt@mattstrapp.net>2024-11-11 11:55:47 -0600
commitb1292752e9617cb0a17ec93b0af1d89fa0d2f077 (patch)
treefdd66dce65499c029d6def5faa329c41d5c701e0 /dot_local/bin
parentmake sure git_editor does not get clobbered by myself (diff)
downloaddotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar.gz
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar.bz2
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar.lz
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar.xz
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.tar.zst
dotfiles-b1292752e9617cb0a17ec93b0af1d89fa0d2f077.zip
Add update script
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r--dot_local/bin/executable_update95
1 files changed, 95 insertions, 0 deletions
diff --git a/dot_local/bin/executable_update b/dot_local/bin/executable_update
new file mode 100644
index 0000000..4cc3756
--- /dev/null
+++ b/dot_local/bin/executable_update
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+set -e
+
+# if doas is installed, use it instead of sudo
+if [ -x "$(command -v doas)" ]; then
+ sudo() {
+ doas "$@"
+ }
+fi
+
+# Get current Distro
+if [ -f /etc/os-release ]; then
+ # shellcheck source=/etc/os-release
+ . /etc/os-release
+ if [ -z "$ID_LIKE" ]; then
+ ID_LIKE=""
+ fi
+else
+ ID=$(uname -s)
+fi
+
+UPDATED=0
+
+set -- "$ID" "$ID_LIKE"
+for i in "$@"; do
+ case "$i" in
+ # YUNO use ID_LIKE, chimera :(
+ alpine | chimera)
+ sudo apk update || return 1
+ sudo apk upgrade || return 1
+ UPDATED=1
+ ;;
+ arch)
+ # TODO: Find a way to prefer one over the other besides hardcoding
+ if [ -x "$(command -v yay)" ]; then
+ yay -Syu || return 1
+ yay -Yc || return 1
+ elif [ -x "$(command -v paru)" ]; then
+ paru -Syu || return 1
+ paru -c || return 1
+ else
+ sudo pacman -Syu || return 1
+ fi
+ UPDATED=1
+ ;;
+ Darwin)
+ brew upgrade -g || return 1
+ brew cleanup || return 1
+ UPDATED=1
+ ;;
+ debian)
+ sudo apt update || return 1
+ sudo apt dist-upgrade || return 1
+ sudo apt autoremove || return 1
+ UPDATED=1
+ ;;
+ gentoo)
+ sudo emaint -a sync || return 1
+ sudo emerge -avuDU --changed-use @world || return 1
+ sudo emerge -av --depclean || return 1
+ UPDATED=1
+ ;;
+ opensuse)
+ sudo zypper refresh || return 1
+ sudo zypper update || return 1
+ sudo zypper clean -a || return 1
+ UPDATED=1
+ ;;
+ *)
+ ;;
+ esac
+ if [ "$UPDATED" -eq 1 ]; then
+ break
+ fi
+done
+
+# Update flatpaks, if flatpak is installed
+if [ -x "$(command -v flatpak)" ]; then
+ flatpak update || return 1
+ UPDATED=1
+fi
+
+# Update snaps, if snap is installed
+if [ -x "$(command -v snap)" ]; then
+ sudo snap refresh || return 1
+ UPDATED=1
+fi
+
+if [ "$UPDATED" -eq 0 ]; then
+ echo "No package managers found!"
+ exit 1
+fi
+
+