weekly lynis
This commit is contained in:
39
lynis/lynis-weekly
Executable file
39
lynis/lynis-weekly
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Lynis Security Report - Weekly Cron Job
|
||||
# Place this file in /etc/cron.weekly/
|
||||
# Make it executable: chmod +x /etc/cron.weekly/lynis-weekly
|
||||
#
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="/opt/lynis-report"
|
||||
|
||||
# Python virtual environment
|
||||
VENV_DIR="$SCRIPT_DIR/venv"
|
||||
|
||||
# Log file
|
||||
LOG_FILE="/var/log/lynis-report.log"
|
||||
|
||||
# Change to script directory
|
||||
cd "$SCRIPT_DIR" || {
|
||||
echo "$(date): ERROR - Cannot change to directory $SCRIPT_DIR" >> "$LOG_FILE"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Log execution start
|
||||
echo "$(date): Starting Lynis weekly report" >> "$LOG_FILE"
|
||||
|
||||
# Activate virtual environment and run the script
|
||||
if [ -d "$VENV_DIR" ]; then
|
||||
"$VENV_DIR/bin/python3" "$SCRIPT_DIR/lynis_report.py" >> "$LOG_FILE" 2>&1
|
||||
else
|
||||
# Fallback to system python3 if venv doesn't exist
|
||||
python3 "$SCRIPT_DIR/lynis_report.py" >> "$LOG_FILE" 2>&1
|
||||
fi
|
||||
|
||||
# Log execution result
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$(date): Lynis weekly report completed successfully" >> "$LOG_FILE"
|
||||
else
|
||||
echo "$(date): ERROR - Lynis weekly report failed with exit code $?" >> "$LOG_FILE"
|
||||
fi
|
||||
Reference in New Issue
Block a user