#!/usr/bin/env bash set -euo pipefail updateApk() { if command -v apk > /dev/null; then gum log -sl info 'Running sudo apk update' && sudo apk update || gum log -sl error 'Failed to run sudo apk update' fi } updateAptGet() { if command -v apt-get > /dev/null; then gum log -sl info 'Running sudo apt-get update' && sudo apt-get update || gum log -sl error 'Failed to run sudo apt-get update' gum log -sl info 'Running sudo apt-get upgrade -y' && sudo apt-get upgrade -y || gum log -sl error 'Failed to run sudo apt-get upgrade -y' fi } updateBrew() { gum log -sl info 'Running brew update' && brew update || gum log -sl error 'Failed to run brew update' gum log -sl info 'Running brew upgrade' && brew upgrade || gum log -sl error 'Failed to run brew upgrade' if [ -d /Applications ] && [ -d /System ]; then ### macOS gum log -sl info 'Running brew upgrade --cask' && brew upgrade --cask || gum log -sl error 'Failed to run brew upgrade --cask' fi } updateCrew() { if command -v crew > /dev/null; then gum log -sl info 'Running crew update' && crew update || gum log -sl error 'Failed to run crew update' fi } updateDnf() { if command -v dnf > /dev/null; then gum log -sl info 'Running sudo dnf update -y' && sudo dnf update -y || gum log -sl error 'Failed to run sudo dnf update -y' fi } updateFlatpak() { if command -v flatpak > /dev/null; then gum log -sl info 'Running sudo flatpak update -y' && sudo flatpak update -y || gum log -sl error 'Failed to run sudo flatpak update -y' fi } updateNix() { if command -v nix-channel > /dev/null; then gum log -sl info 'Running nix-channel --update' && nix-channel --update || gum log -sl error 'Failed to run nix-channel --update' fi } updatePacman() { if command -v pacman > /dev/null; then gum log -sl info 'Running sudo pacman -Syu' && sudo pacman -Syu || gum log -sl error 'Failed to run sudo pacman -Syu' fi } updatePort() { if command -v port > /dev/null; then gum log -sl info 'Running sudo port sync' && sudo port sync || gum log -sl error 'Failed to run sudo port sync' fi } updateSnap() { if command -v snap > /dev/null; then gum log -sl info 'Running sudo snap refresh' && sudo snap refresh || gum log -sl error 'Failed to run sudo snap refresh' fi } updateZypper() { if command -v zypper > /dev/null; then gum log -sl info 'Running sudo zypper update' && sudo zypper update || gum log -sl error 'Failed to run sudo zypper update' fi } if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then gum log -sl info 'The DEBUG or DEBUG_MODE environment variable is set so updates will be run synchronously' updateApk updateAptGet updateBrew updateCrew updateDnf updateFlatpak updateNix updatePacman updatePort updateSnap updateZypper else updateApk & updateAptGet & updateBrew & updateCrew & updateDnf & updateFlatpak & updateNix & updatePacman & updatePort & updateSnap & updateZypper & wait fi gum log -sl info 'Finished running update-system'