From 1d7801c1ea5b1730a4c95d05a400bc1750079b1f Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 6 Sep 2020 15:51:42 +0200 Subject: [PATCH] Extend upgrade function to support local updates --- config/bash/scripts.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/config/bash/scripts.sh b/config/bash/scripts.sh index 26bd615..368562b 100755 --- a/config/bash/scripts.sh +++ b/config/bash/scripts.sh @@ -14,10 +14,20 @@ function encode-with-ffmpeg() { ffmpeg -i "$movie" -c:v libx264 -preset veryslow -b:v 630k -pass 2 -c:a aac -b:a 128k "$output" } -function run-remote-apt-upgrade() { - host=$1 +function run-apt-upgrade() { + local upgrade_seq="sudo apt clean && sudo apt update && sudo apt upgrade && sudo apt autoremove && sudo tripwire --check --interactive" + local host=$1 - ssh "$host" -t "tmux new-session -d -A -s apt-updates \; send-keys 'sudo apt clean && sudo apt update && sudo apt upgrade && sudo apt autoremove && sudo tripwire --check --interactive' ENTER \; attach" + if [[ -z $host ]]; then + echo "No host name provided, exiting." + exit 1; + elif [[ $host = $(hostname) || $host = $(hostname --fqdn) ]]; then + echo "Running upgrade command locally." + eval "${upgrade_seq}" + else + echo "Running upgrade command remotely." + ssh "$host" -t "tmux new-session -d -A -s apt-updates \; send-keys '${upgrade_seq}' ENTER \; attach" + fi } function tmux-main() {