#!/usr/bin/env bash # Install the Pit Log sync service on Debian or Ubuntu. # The Proxmox helper runs this inside the new container. set -euo pipefail if [[ "$(id -u)" -ne 0 ]]; then echo "Run this as root inside the container." exit 1 fi export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y python3 openssl ca-certificates install -d -o root -g root -m 755 /opt/pitlog if ! id pitlog >/dev/null 2>&1; then useradd --system --home-dir /var/lib/pitlog --shell /usr/sbin/nologin pitlog fi install -d -o pitlog -g pitlog -m 750 /var/lib/pitlog /etc/pitlog SOURCE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/pitlog_sync.py" if [[ ! -f "$SOURCE" && -f /tmp/pitlog_sync.py ]]; then SOURCE=/tmp/pitlog_sync.py fi if [[ ! -f "$SOURCE" ]]; then echo "pitlog_sync.py was not next to this script." exit 1 fi install -o root -g pitlog -m 640 "$SOURCE" /opt/pitlog/pitlog_sync.py if [[ ! -s /etc/pitlog/token ]]; then openssl rand -hex 32 > /etc/pitlog/token fi chown root:pitlog /etc/pitlog/token chmod 640 /etc/pitlog/token PORT="${PITLOG_PORT:-8787}" cat > /etc/systemd/system/pitlog-sync.service <