summaryrefslogtreecommitdiff
path: root/autologs
diff options
context:
space:
mode:
authorspice <git@spice>2025-09-24 00:16:19 +0000
committerspice <git@spice>2025-09-24 00:16:19 +0000
commite8c2c9f4f5bc997d67b330de982aef601ea31a55 (patch)
treebde75c900fc8ea20d2fd1718e8ba56b3a2e6e7bb /autologs
initial communismHEADmaster
Diffstat (limited to 'autologs')
-rwxr-xr-xautologs34
1 files changed, 34 insertions, 0 deletions
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;