mybin

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

upgrades (819B)


      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      ~/bin/wake $m;
     18      sleep 5;
     19      ssh -t $m 'sudo apt-get autoclean && sudo apt autoremove && sudo apt update && sudo apt dist-upgrade';
     20      echo \"\n\n=== testing connection to $m ... ===\n\n\";
     21      ssh -t $m 'echo this is fine';
     22      echo \"\n\n=== done upgrading $m ===\n\n\";
     23      exec zsh"
     24 done
     25 
     26 # now, attach to the created screen session
     27 screen -x apt
     28