mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

upgrades (785B)


      1 #!/bin/bash
      2 
      3 # upgrade all hosts specified in ARGV
      4 
      5 # start screen session named "apt"
      6 screen -S apt -dm 'zsh'
      7 
      8 for m in $@
      9 do
     10   # start new terminal in the current session, doing the following
     11   # - ~/bin/wake: wake host using wake-on-LAN if necessary
     12   # - wait for host to wake up
     13   # - SSH on host and do the upgrades
     14   # - test if SSH-ing to the host still works
     15   screen -S apt -x -X screen -t $m zsh -c \
     16     "echo \"=== upgrading $m ===\n\n\";
     17      ssh -t $m 'sudo apt-get autoclean && sudo apt autoremove && sudo apt update && sudo apt dist-upgrade';
     18      echo \"\n\n=== testing connection to $m ... ===\n\n\";
     19      ssh -t $m 'echo this is fine';
     20      echo \"\n\n=== done upgrading $m ===\n\n\";
     21      exec zsh"
     22 done
     23 
     24 # now, attach to the created screen session
     25 screen -x apt
     26