blob: ca2fdbdc9efa411014a64661814d9f74e4e902b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|