deluged_init.sh 820 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. /sbin/openvpn_init.sh &
  3. # Match the owner of the mounted volumes (PUID/PGID), default 1000:1000
  4. PUID="${PUID:-1000}"
  5. PGID="${PGID:-1000}"
  6. if [ "$(id -u deluge)" != "$PUID" ] || [ "$(id -g deluge)" != "$PGID" ]; then
  7. groupmod -o -g "$PGID" deluge
  8. usermod -o -u "$PUID" -g "$PGID" deluge
  9. fi
  10. # /config is usually a mounted volume; make sure the deluge user can write to it
  11. chown -R deluge:deluge /config
  12. # Starting before the tunnel is up makes the first announces and DHT bootstrap fail
  13. echo "waiting for ${VPN_DEV:-tun0}"
  14. until ip -4 addr show dev "${VPN_DEV:-tun0}" 2>/dev/null | grep -q inet; do
  15. sleep 1
  16. done
  17. if [ "${PIA_PORT_FORWARD:-true}" = "true" ]; then
  18. /sbin/pia_port_forward.sh &
  19. fi
  20. echo starting deluge on port $PORT
  21. su deluge bash -c "deluged -c /config -d -p $PORT -u 0.0.0.0"