forked from jkef80/Filament-Management
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdate.sh
More file actions
46 lines (36 loc) · 978 Bytes
/
update.sh
File metadata and controls
46 lines (36 loc) · 978 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
APP_DIR="/opt/filament-management"
SERVICE_NAME="filament-management"
REPO_URL="https://github.com/koen01/CFSync.git"
if [[ ${EUID} -ne 0 ]]; then
echo "Please run with sudo"
exit 1
fi
REAL_USER="${SUDO_USER:-}"
if [[ -z "$REAL_USER" || "$REAL_USER" == "root" ]]; then
echo "Run via sudo from normal user"
exit 1
fi
echo "Updating CFSync..."
rm -rf /tmp/filament-update
git clone --depth 1 "$REPO_URL" /tmp/filament-update
rsync -a \
--exclude ".git/" \
--exclude "data/" \
--exclude "venv/" \
--exclude "__pycache__/" \
/tmp/filament-update/ "$APP_DIR/"
rm -rf /tmp/filament-update
sudo -u "$REAL_USER" bash -lc "
cd '$APP_DIR'
if [[ ! -f venv/bin/activate ]]; then
echo 'Recreating virtual environment...'
python3 -m venv venv
fi
source venv/bin/activate
pip install -r requirements.txt
"
systemctl restart "$SERVICE_NAME"
echo "✅ Updated successfully"
echo "Logs: sudo journalctl -u ${SERVICE_NAME} -f"