Install the sync server from this repo now that the separate installer is gone.
This commit is contained in:
1 parent
1030bac79e
commit
3665f7941e
7 files changed
+3
-178
No files matched your search
@@ -1,5 +1,2 @@
|
|||||||
sync/*.sh text eol=lf
|
|
||||||
sync/*.py text eol=lf
|
sync/*.py text eol=lf
|
||||||
sync/*.yaml text eol=lf
|
sync/*.yaml text eol=lf
|
||||||
sync/**/*.sh text eol=lf
|
|
||||||
sync/**/*.py text eol=lf
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pit Log sync runs on the Pelican panel. This script does not create a container.
|
|
||||||
echo "Pit Log sync uses the Pelican panel you already have."
|
|
||||||
echo "In the panel, import this egg:"
|
|
||||||
echo "https://git.ny.daprogs.com/RallyBlock/Pit-Log-App-Server-Installer-Proxmox/raw/branch/main/egg-pitlog.yaml"
|
|
||||||
echo "Then create a server from Pit Log sync, give it one port, and start it."
|
|
||||||
echo "The console prints the token. On each phone, open Car and enter http://NODE:PORT plus that token."
|
|
||||||
exit 0
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
meta:
|
meta:
|
||||||
version: PLCN_v3
|
version: PLCN_v3
|
||||||
update_url: https://git.ny.daprogs.com/RallyBlock/Pit-Log-App-Server-Installer-Proxmox/raw/branch/main/egg-pitlog.yaml
|
update_url: https://git.ny.daprogs.com/RallyBlock/Pit-Log-App/raw/branch/main/sync/egg-pitlog.yaml
|
||||||
exported_at: '2026-10-22T20:00:00+00:00'
|
exported_at: '2026-10-22T20:00:00+00:00'
|
||||||
name: Pit Log sync
|
name: Pit Log sync
|
||||||
author: pitlog@ny.daprogs.com
|
author: pitlog@ny.daprogs.com
|
||||||
uuid: 4f8c2e91-6b3a-4d17-9e50-a1c7d8b24f06
|
uuid: 4f8c2e91-6b3a-4d17-9e50-a1c7d8b24f06
|
||||||
description: Sync server for the Pit Log phone app. Create this on the existing Pelican panel. The console prints the address port and the token.
|
description: Sync server for the Pit Log phone app. Create this on the existing Pelican panel. Phones use this server's address and the token from each car.
|
||||||
tags: {}
|
tags: {}
|
||||||
features: {}
|
features: {}
|
||||||
docker_images:
|
docker_images:
|
||||||
@@ -28,7 +28,7 @@ scripts:
|
|||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y curl ca-certificates
|
apt-get install -y curl ca-certificates
|
||||||
mkdir -p /mnt/server
|
mkdir -p /mnt/server
|
||||||
curl -fsSL "https://git.ny.daprogs.com/RallyBlock/Pit-Log-App-Server-Installer-Proxmox/raw/branch/main/pitlog_sync.py" -o /mnt/server/pitlog_sync.py
|
curl -fsSL "https://git.ny.daprogs.com/RallyBlock/Pit-Log-App/raw/branch/main/sync/pitlog_sync.py" -o /mnt/server/pitlog_sync.py
|
||||||
test -s /mnt/server/pitlog_sync.py
|
test -s /mnt/server/pitlog_sync.py
|
||||||
echo "install complete"
|
echo "install complete"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Pit Log sync. Runs inside the container the helper script just created.
|
|
||||||
|
|
||||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
|
||||||
color
|
|
||||||
verb_ip6
|
|
||||||
catch_errors
|
|
||||||
setting_up_container
|
|
||||||
network_check
|
|
||||||
update_os
|
|
||||||
|
|
||||||
PITLOG_BASE="https://git.ny.daprogs.com/RallyBlock/Pit-Log-App-Server-Installer-Proxmox/raw/branch/main"
|
|
||||||
|
|
||||||
msg_info "Installing Pit Log sync"
|
|
||||||
$STD apt-get update
|
|
||||||
$STD 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
|
|
||||||
curl -fsSL "${PITLOG_BASE}/pitlog_sync.py" -o /opt/pitlog/pitlog_sync.py
|
|
||||||
chown root:pitlog /opt/pitlog/pitlog_sync.py
|
|
||||||
chmod 640 /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
|
|
||||||
cat >/etc/systemd/system/pitlog-sync.service <<'EOF'
|
|
||||||
[Unit]
|
|
||||||
Description=Pit Log sync
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=pitlog
|
|
||||||
Group=pitlog
|
|
||||||
Environment=PITLOG_TOKEN_FILE=/etc/pitlog/token
|
|
||||||
Environment=PITLOG_DB=/var/lib/pitlog/sync.db
|
|
||||||
Environment=PITLOG_PORT=8787
|
|
||||||
ExecStart=/usr/bin/python3 /opt/pitlog/pitlog_sync.py
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=2
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now pitlog-sync.service
|
|
||||||
msg_ok "Installed Pit Log sync"
|
|
||||||
|
|
||||||
motd_ssh
|
|
||||||
customize
|
|
||||||
cleanup_lxc
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
#!/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 <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Pit Log sync
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=pitlog
|
|
||||||
Group=pitlog
|
|
||||||
Environment=PITLOG_TOKEN_FILE=/etc/pitlog/token
|
|
||||||
Environment=PITLOG_DB=/var/lib/pitlog/sync.db
|
|
||||||
Environment=PITLOG_PORT=${PORT}
|
|
||||||
ExecStart=/usr/bin/python3 /opt/pitlog/pitlog_sync.py
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=2
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable --now pitlog-sync.service
|
|
||||||
|
|
||||||
TOKEN="$(cat /etc/pitlog/token)"
|
|
||||||
echo
|
|
||||||
echo "Pit Log sync is running on port ${PORT}."
|
|
||||||
echo "Token: ${TOKEN}"
|
|
||||||
echo "On each phone, open Car and enter this address and the same token."
|
|
||||||
echo "Use http:// when the phone is on the same network. Use https:// if a reverse proxy serves the port."
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import secrets
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
@@ -53,16 +52,6 @@ def listen_port():
|
|||||||
return 8787
|
return 8787
|
||||||
|
|
||||||
|
|
||||||
def token_path():
|
|
||||||
configured = os.environ.get("PITLOG_TOKEN_FILE")
|
|
||||||
if configured:
|
|
||||||
return configured
|
|
||||||
home = os.environ.get("HOME", "")
|
|
||||||
if home:
|
|
||||||
return os.path.join(home, ".pitlog-token")
|
|
||||||
return "/etc/pitlog/token"
|
|
||||||
|
|
||||||
|
|
||||||
def legacy_token():
|
def legacy_token():
|
||||||
inline = os.environ.get("PITLOG_TOKEN", "").strip().lower()
|
inline = os.environ.get("PITLOG_TOKEN", "").strip().lower()
|
||||||
if inline:
|
if inline:
|
||||||
@@ -199,27 +188,6 @@ def connect():
|
|||||||
_spaces[path] = _db
|
_spaces[path] = _db
|
||||||
|
|
||||||
|
|
||||||
def token():
|
|
||||||
inline = os.environ.get("PITLOG_TOKEN", "").strip()
|
|
||||||
if inline:
|
|
||||||
return inline
|
|
||||||
path = token_path()
|
|
||||||
try:
|
|
||||||
with open(path, "r", encoding="utf-8") as handle:
|
|
||||||
saved = handle.read().strip()
|
|
||||||
except FileNotFoundError:
|
|
||||||
saved = ""
|
|
||||||
if saved:
|
|
||||||
return saved
|
|
||||||
generated = secrets.token_hex(32)
|
|
||||||
folder = os.path.dirname(path)
|
|
||||||
if folder:
|
|
||||||
os.makedirs(folder, exist_ok=True)
|
|
||||||
with open(path, "w", encoding="utf-8") as handle:
|
|
||||||
handle.write(generated)
|
|
||||||
return generated
|
|
||||||
|
|
||||||
|
|
||||||
def current_rev(db):
|
def current_rev(db):
|
||||||
return int(db.execute("SELECT value FROM meta WHERE key = 'rev'").fetchone()["value"])
|
return int(db.execute("SELECT value FROM meta WHERE key = 'rev'").fetchone()["value"])
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pit Log sync runs on the Pelican panel. This script does not create a container.
|
|
||||||
echo "Pit Log sync uses the Pelican panel you already have."
|
|
||||||
echo "In the panel, import this egg:"
|
|
||||||
echo "https://git.ny.daprogs.com/RallyBlock/Pit-Log-App-Server-Installer-Proxmox/raw/branch/main/egg-pitlog.yaml"
|
|
||||||
echo "Then create a server from Pit Log sync, give it one port, and start it."
|
|
||||||
echo "The console prints the token. On each phone, open Car and enter http://NODE:PORT plus that token."
|
|
||||||
exit 0
|
|
||||||
Reference in new issue
Block a user