-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·54 lines (46 loc) · 1.59 KB
/
update.sh
File metadata and controls
executable file
·54 lines (46 loc) · 1.59 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
#!/usr/bin/env bash
set -euo pipefail
# Pull latest sources, rebuild evuproxy, and restart services that use it.
# From repo root: ./scripts/update.sh
#
# - Builds with scripts/rebuild.sh (see that script for PREFIX / OUT).
# - If EvuProxy systemd units are installed under /etc/systemd/system/, installs
# the binary to PREFIX (default /usr/local) and restarts active units.
# - If this repo's default Docker Compose UI stack is running, rebuilds and
# recreates those containers.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"
git pull
SYSTEMD_UNITS=0
if [[ -f /etc/systemd/system/evuproxy-api.service ]] || [[ -f /etc/systemd/system/evuproxy.service ]]; then
SYSTEMD_UNITS=1
fi
if [[ "$SYSTEMD_UNITS" -eq 1 ]]; then
if [[ "$(id -u)" -eq 0 ]]; then
"$SCRIPT_DIR/rebuild.sh" --install
else
sudo "$SCRIPT_DIR/rebuild.sh" --install
fi
else
"$SCRIPT_DIR/rebuild.sh"
fi
if [[ "$SYSTEMD_UNITS" -eq 1 ]] && command -v systemctl >/dev/null 2>&1; then
SUDO=()
if [[ "$(id -u)" -ne 0 ]]; then
SUDO=(sudo)
fi
for unit in evuproxy.service evuproxy-api.service; do
if systemctl is-active --quiet "$unit" 2>/dev/null; then
"${SUDO[@]}" systemctl restart "$unit"
fi
done
fi
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
if [[ -f "$REPO_ROOT/docker-compose.yml" ]]; then
if docker compose -f "$REPO_ROOT/docker-compose.yml" ps -q 2>/dev/null | grep -q .; then
docker compose -f "$REPO_ROOT/docker-compose.yml" up --build -d
fi
fi
fi
echo "Update complete."