mybin

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

move_journals (492B)


      1 #!/bin/bash
      2 
      3 HOST=$(hostname | cut -d'.' -f1)
      4 FILE="$HOME/config/private/systemd_journals"
      5 
      6 # hack: search first in local file, then in all files
      7 DEST="$(grep "^$HOST " "$FILE" | cut -d' ' -f2 | head -1)"
      8 
      9 if [[ -z "$DEST" ]]
     10 then
     11   # not moving anything
     12   exit 0
     13 fi
     14 
     15 # https://stackoverflow.com/questions/2937407/test-whether-a-glob-has-any-matches-in-bash
     16 if compgen -G /var/log/journal/*/*@* > /dev/null; then
     17   sudo mv /var/log/journal/*/*@* "$DEST"
     18   sudo chown -R a3nm:a3nm "$DEST"
     19 fi
     20