-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathupdate.sh
executable file
·57 lines (49 loc) · 1.32 KB
/
update.sh
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
#!/usr/bin/env bash
cd "$(dirname "$0")"
if [ "$1" != "force" ]; then
echo "Checking for updates..."
git fetch -q
NEW_COMMITS="$(git rev-list HEAD...@{upstream} --count)"
if [ "$NEW_COMMITS" -gt 0 ]; then
echo "Update available!"
else
echo "No update available. Use '$0 force' to skip the check."
exit 0
fi
fi
NEED_RESTART=0
OSNAME="$(uname -s)"
if [ "$OSNAME" == "FreeBSD" ]; then
echo "Checking Zigbee2MQTT status..."
if service zigbee2mqtt status >/dev/null; then
echo "Stopping Zigbee2MQTT..."
service zigbee2mqtt stop
NEED_RESTART=1
fi
else
if which systemctl 2> /dev/null > /dev/null; then
echo "Checking Zigbee2MQTT status..."
if systemctl is-active --quiet zigbee2mqtt; then
echo "Stopping Zigbee2MQTT..."
sudo systemctl stop zigbee2mqtt
NEED_RESTART=1
fi
else
echo "Skipped stopping Zigbee2MQTT, no systemctl found"
fi
fi
echo "Updating..."
git pull --no-rebase
echo "Installing dependencies..."
pnpm i --frozen-lockfile
echo "Building..."
pnpm run build
if [ $NEED_RESTART -eq 1 ]; then
echo "Starting Zigbee2MQTT..."
if [ "$OSNAME" == "FreeBSD" ]; then
service zigbee2mqtt start
else
sudo systemctl start zigbee2mqtt
fi
fi
echo "Done!"