Initial Awawawa
This commit is contained in:
65
docker/entrypoint.sh
Executable file
65
docker/entrypoint.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
# Test container entrypoint. PB_ROLE=target|client selects the role.
|
||||
set -eu
|
||||
|
||||
ROLE=${PB_ROLE:-client}
|
||||
CONF=/etc/patchbay/patchbay.conf
|
||||
mkdir -p /etc/patchbay /shared
|
||||
|
||||
if [ "$ROLE" = target ]; then
|
||||
if [ ! -f "$CONF" ]; then
|
||||
cat > "$CONF" <<EOF
|
||||
Role = target
|
||||
TargetPort = 2222
|
||||
HubPort = 7701
|
||||
WebPort = 8443
|
||||
SysopUser = admin
|
||||
SysopEmail = ${PB_SYSOP_EMAIL:-admin@example.org}
|
||||
SysopPassword = ${PB_SYSOP_PASSWORD:-patchbay-test-pw}
|
||||
MailHost = ${PB_MAILHOST:-log}
|
||||
EOF
|
||||
chmod 600 "$CONF"
|
||||
# Optional real SMTP account, mounted at runtime (INI [smtp] section).
|
||||
if [ -f /run/secrets/smtp.conf ]; then
|
||||
python3 - "$CONF" <<'PYEOF'
|
||||
import configparser, sys
|
||||
sys.path.insert(0, "/usr/local/lib/patchbay/web")
|
||||
from patchbay_web.conf import Config
|
||||
c = configparser.RawConfigParser()
|
||||
c.read("/run/secrets/smtp.conf")
|
||||
s = c["smtp"]
|
||||
Config(sys.argv[1]).update({
|
||||
"MailHost": s["host"], "MailPort": s["port"],
|
||||
"MailSecurity": "ssl" if s.getboolean("ssl", fallback=False) else "starttls",
|
||||
"MailUser": s["user"], "MailPassword": s["password"], "MailFrom": s.get("from", s["user"]),
|
||||
})
|
||||
PYEOF
|
||||
fi
|
||||
fi
|
||||
patchbayd -c "$CONF" &
|
||||
sleep 0.5
|
||||
/usr/local/lib/patchbay/patchbay-sshd "$CONF" &
|
||||
cd /usr/local/lib/patchbay/web
|
||||
python3 -m patchbay_web -c "$CONF" serve &
|
||||
else
|
||||
if [ ! -f "$CONF" ]; then
|
||||
cat > "$CONF" <<EOF
|
||||
Role = client
|
||||
TargetHost = ${PB_TARGET:-target}
|
||||
TargetPort = 2222
|
||||
IdentityFile = /etc/patchbay/id_ed25519
|
||||
EOF
|
||||
fi
|
||||
[ -f /etc/patchbay/id_ed25519 ] || ssh-keygen -q -t ed25519 -N '' -C "$(hostname)" -f /etc/patchbay/id_ed25519
|
||||
cp /etc/patchbay/id_ed25519.pub "/shared/$(hostname).pub"
|
||||
|
||||
# Test services: TCP and UDP echo.
|
||||
socat TCP-LISTEN:9000,fork,reuseaddr EXEC:cat &
|
||||
socat UDP-RECVFROM:9001,fork EXEC:cat &
|
||||
# Discard sink for throughput tests.
|
||||
socat -u TCP-LISTEN:9002,fork,reuseaddr OPEN:/dev/null &
|
||||
patchbayd -c "$CONF" &
|
||||
fi
|
||||
|
||||
# Exit when any service dies so the test notices.
|
||||
wait -n
|
||||
Reference in New Issue
Block a user