Added cgi-bin scripts

This commit is contained in:
Russel Yasol
2025-01-17 14:57:15 +08:00
parent 397e0de45a
commit b8f9feef20
46 changed files with 3603 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# Script path
SCRIPT_PATH=$(readlink -f "$0")
# Fix the spacing in the cron line to ensure exactly 5 fields
CRON_LINE="0 0 * * * $SCRIPT_PATH"
# Install crontab if not already present
if ! crontab -l | grep -Fq "$SCRIPT_PATH"; then
# Get existing crontab - ensuring clean formatting
(crontab -l 2>/dev/null | grep -v "$SCRIPT_PATH" || true; echo "$CRON_LINE") | crontab -
if [ $? -eq 0 ]; then
logger -t log_cleanup "Successfully installed crontab job"
else
logger -t log_cleanup "Failed to install crontab job"
exit 1
fi
fi
# Clean specified log files using echo redirection
echo "" > /tmp/apn_profiles.log
echo "" > /tmp/imei_profiles.log
echo "" > /var/log/at_commands.log
# Add error handling
if [ $? -ne 0 ]; then
logger -t log_cleanup "Failed to clean one or more log files"
exit 1
fi
logger -t log_cleanup "Successfully cleaned log files"