#!/bin/bash
set -euo pipefail

# The legacy image's systemd replacement can supervise units without a real
# PID-1 systemd. Start them explicitly and keep the container foreground alive.
systemctl daemon-reload || true
systemctl start trojan
systemctl start trojan-web
systemctl start trojan-acme-challenge
systemctl enable trojan trojan-web trojan-acme-challenge trojan-acme-renew.timer || true
(
  while sleep 300; do
    /usr/local/sbin/rotate-trojan-log || true
  done
) &
exec tail -f /dev/null
