-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate.sh
More file actions
35 lines (29 loc) · 1.17 KB
/
update.sh
File metadata and controls
35 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# update.sh - Automatic update script
# Add this to crontab: 0 * * * * /path/to/distributed-encodes/update.sh >> /tmp/update.log 2>&1
# Navigate to the project directory (directory of this script)
cd "$(dirname "$0")" || exit
# Fetch latest changes without merging
git fetch origin
# Check if there are updates
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse @{u})
if [ "$LOCAL" != "$REMOTE" ]; then
echo "[$(date)] Update found. Pulling changes..."
git pull origin main
# Install/Update dependencies
if [ -f requirements.txt ]; then
pip3 install -r requirements.txt
fi
# Restart the service (Adjust if using a different service name or system/user scope)
# Using 'systemctl --user' is recommended for non-root deployments
if systemctl --user is-active --quiet distributed-encodes.service; then
systemctl --user restart distributed-encodes.service
echo "[$(date)] Service restarted successfully."
else
# Fallback for system-level service or if not running
echo "[$(date)] Service not running or restart command failed. Please check manually."
fi
else
echo "[$(date)] No updates available."
fi