mybin

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

commit 4c77e4ea8724e8b563f9e6ae22c1b0a106f9fd68
parent 32eec499e5fa7f30a356725eaf1719aa1720f7ba
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 24 Jul 2020 16:59:23 +0200

move_journals

Diffstat:
move_journals | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/move_journals b/move_journals @@ -0,0 +1,20 @@ +#!/bin/bash + +HOST=$(hostname | cut -d'.' -f1) +FILE="$HOME/config/private/systemd_journals" + +# hack: search first in local file, then in all files +DEST="$(grep "^$HOST " "$FILE" | cut -d' ' -f2 | head -1)" + +if [[ -z "$DEST" ]] +then + # not moving anything + exit 0 +fi + +# https://stackoverflow.com/questions/2937407/test-whether-a-glob-has-any-matches-in-bash +if compgen -G /var/log/journal/*/*@* > /dev/null; then + sudo mv /var/log/journal/*/*@* "$DEST" + sudo chown -R a3nm:a3nm "$DEST" +fi +