From e8c2c9f4f5bc997d67b330de982aef601ea31a55 Mon Sep 17 00:00:00 2001 From: spice Date: Wed, 24 Sep 2025 00:16:19 +0000 Subject: initial communism --- autologs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 autologs (limited to 'autologs') diff --git a/autologs b/autologs new file mode 100755 index 0000000..5359142 --- /dev/null +++ b/autologs @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +scriptlocalpath=""; +dbpass=''; + +PrepareInputFiles() { + local sincedate=$1; + local untildate=$2; + local inputfilename=$3; + journalctl -u ssh -S "${sincedate}" -U "${untildate}" > "${scriptlocalpath}/${inputfilename}"; +} + +ClearTempFiles() { + local UpperRangeShort=$(date '+%Y-%m' --date 'today'); + local inputfilename=$1; + if [ -f "${scriptlocalpath}/${inputfilename}" ]; then + mv "${scriptlocalpath}/${inputfilename}" "${scriptlocalpath}/backup/${UpperRangeShort}${inputfilename}"; + else + echo "did not find ${inputfilename} file"; + fi +} + +main() { + local UpperRangeShort=$(date '+%Y-%m' --date 'today'); + local LowerRangeShort=$(date '+%Y-%m' --date '1 week ago'); + local UpperRange="${UpperRangeShort}-01"; + local LowerRange="${LowerRangeShort}-01"; + local logfilename='sshlogs'; + PrepareInputFiles ${LowerRange} ${UpperRange} ${logfilename}; + python3 "${scriptlocalpath}/ssh_login_parser.py" ${LowerRange} ${UpperRange} ${logfilename} ${dbpass}; + ClearTempFiles ${logfilename}; +} + +main; -- cgit v1.2.3