FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
  • Dr Adam Thorn's avatar
    71da2ff1
    Escape $ in ssh commands used in prepare scripts · 71da2ff1
    Dr Adam Thorn authored
    Our backup logs are generally full of
    
    + ssh -p 22 -o ConnectTimeout=10 root@openvpn2020.ch.cam.ac.uk '
      umask 077
      FILELIST=`tempfile`
      CONFLIST=`tempfile`
      mkdir -p /var/adm/backup
      # Make logrotate use datestamps
      if ! grep -q dateext /etc/logrotate.conf ; then sed  -i '\''s/^include/dateext\ninclude/'\'' /etc/logrotate.conf ; fi
      # Which packages are installed?
      dpkg --get-selections | awk '\'' { print $1 ; } '\'' >/var/adm/backup/packages
      cat /var/lib/dpkg/info/*.list | while read F ; do [ -f "$F" ] && echo "$F" ; done | sort > $FILELIST
      awk '\''/Description:/ { flag = 0 } ; flag == 1 { print $1 ; }  ; /Conffiles:/ { flag = 1  } ; '\'' </var/lib/dpkg/status |  sort >$CONFLIST
      diff -u $FILELIST $CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
      rm
     '
    rm: missing operand
    
    because we're not escaping the args to that final rm command! This means we gradually fill
    up /tmp, especially on machines that are infrequently rebooted (e.g. calculon)
    71da2ff1
    History
    Escape $ in ssh commands used in prepare scripts
    Dr Adam Thorn authored
    Our backup logs are generally full of
    
    + ssh -p 22 -o ConnectTimeout=10 root@openvpn2020.ch.cam.ac.uk '
      umask 077
      FILELIST=`tempfile`
      CONFLIST=`tempfile`
      mkdir -p /var/adm/backup
      # Make logrotate use datestamps
      if ! grep -q dateext /etc/logrotate.conf ; then sed  -i '\''s/^include/dateext\ninclude/'\'' /etc/logrotate.conf ; fi
      # Which packages are installed?
      dpkg --get-selections | awk '\'' { print $1 ; } '\'' >/var/adm/backup/packages
      cat /var/lib/dpkg/info/*.list | while read F ; do [ -f "$F" ] && echo "$F" ; done | sort > $FILELIST
      awk '\''/Description:/ { flag = 0 } ; flag == 1 { print $1 ; }  ; /Conffiles:/ { flag = 1  } ; '\'' </var/lib/dpkg/status |  sort >$CONFLIST
      diff -u $FILELIST $CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
      rm
     '
    rm: missing operand
    
    because we're not escaping the args to that final rm command! This means we gradually fill
    up /tmp, especially on machines that are infrequently rebooted (e.g. calculon)
Code owners