From 8c1a40d00ca69f2194a9f7c4cf4e884a2d225d3d Mon Sep 17 00:00:00 2001 From: hc Date: Sat, 1 Feb 2025 11:07:07 +0800 Subject: formatednicely --- cron_setup.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 cron_setup.sh (limited to 'cron_setup.sh') diff --git a/cron_setup.sh b/cron_setup.sh new file mode 100755 index 0000000..ca2fdbd --- /dev/null +++ b/cron_setup.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# add client_manager python to crontab + +if [ "$EUID" -ne 0 ]; then + echo "ERROR: This script must be run as root" + exit 1 +fi + +# Get script's directory +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# Create a temporary file with the cron entry +echo "@reboot /usr/bin/python3 $SCRIPT_DIR/client_manager.py" > temp_cron + +# Append this to the user's crontab +crontab -l > current_cron 2>/dev/null || true # Get current crontab or empty if none exists +cat temp_cron >> current_cron +crontab current_cron + +# Clean up temporary files +rm temp_cron current_cron -- cgit v1.2.3-70-g09d2