-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
57 lines (47 loc) · 1.33 KB
/
update.sh
File metadata and controls
57 lines (47 loc) · 1.33 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# HomeLog Sentinel Update Script
# Run as: sudo ./update.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "=== HomeLog Sentinel Update ==="
echo ""
# Check if running as root (needed for systemd)
if [ "$EUID" -ne 0 ]; then
echo "Note: Run with sudo to restart the service automatically"
RESTART_SERVICE=false
else
RESTART_SERVICE=true
fi
# Save current requirements hash
OLD_REQ_HASH=""
if [ -f requirements.txt ]; then
OLD_REQ_HASH=$(md5sum requirements.txt | cut -d' ' -f1)
fi
# Pull latest changes
echo "Pulling latest changes..."
git pull origin main
# Check if requirements changed
NEW_REQ_HASH=""
if [ -f requirements.txt ]; then
NEW_REQ_HASH=$(md5sum requirements.txt | cut -d' ' -f1)
fi
# Update dependencies if requirements changed
if [ "$OLD_REQ_HASH" != "$NEW_REQ_HASH" ]; then
echo ""
echo "Requirements changed, updating dependencies..."
./venv/bin/pip install -r requirements.txt
else
echo "Dependencies unchanged."
fi
# Restart service if running and we have permissions
if [ "$RESTART_SERVICE" = true ]; then
if systemctl is-active --quiet homelog-sentinel; then
echo ""
echo "Restarting service..."
systemctl restart homelog-sentinel
echo "Service restarted."
fi
fi
echo ""
echo "=== Update complete ==="