32 lines
958 B
Bash
Executable File
32 lines
958 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$ROOT_DIR"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "install-auto-deploy-service.sh must run as root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
enabled="$(python3 "$ROOT_DIR/scripts/env-value.py" "$ROOT_DIR/.env" TESTBOX_AUTODEPLOY_ENABLED 1)"
|
|
unit_src="$ROOT_DIR/systemd/chatapp-test-auto-deploy.service"
|
|
unit_dst="/etc/systemd/system/chatapp-test-auto-deploy.service"
|
|
|
|
if [ ! -f "$unit_src" ]; then
|
|
echo "missing unit file: $unit_src" >&2
|
|
exit 1
|
|
fi
|
|
|
|
install -m 0644 "$unit_src" "$unit_dst"
|
|
systemctl daemon-reload
|
|
|
|
if [ "$enabled" = "1" ] || [ "$enabled" = "true" ] || [ "$enabled" = "yes" ]; then
|
|
systemctl enable --now chatapp-test-auto-deploy.service
|
|
systemctl restart chatapp-test-auto-deploy.service
|
|
else
|
|
systemctl disable --now chatapp-test-auto-deploy.service >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
systemctl --no-pager --full status chatapp-test-auto-deploy.service || true
|