# what runs inside, as whom, and the entrypoint read in full
## processes:
    PID USER     COMMAND
      1 root     /package/admin/s6/command/s6-svscan -d4 -- /run/service
     19 root     s6-supervise s6-linux-init-shutdownd
     21 root     /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -d3 -c /run/s6/basedir -g 3000 -C -B
     38 root     s6-supervise svc-cron
     39 root     s6-supervise s6rc-oneshot-runner
     40 root     s6-supervise s6rc-fdholder
     41 root     s6-supervise svc-sabnzbd
     49 root     /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/command/s6-sudod -t 30000 -- /package/admin/s6-rc/command/s6-rc-oneshot-run -l ../.. --
    187 root     busybox crond -f -S -l 5
    308 root     sh -c ps -o pid,user,args 2>/dev/null || ps aux
    314 root     ps -o pid,user,args

## the compose entrypoint this template sets:
["/bin/sh","-c","CONF=/config/sabnzbd.ini\nif [ ! -f \"$CONF\" ]; then\n  mkdir -p /config\n  {\n    printf '%s\\n' '[misc]'\n    printf '%s\\n' 'host = 0.0.0.0'\n    printf '%s\\n' 'port = 8080'\n    printf '%s\\n' 'username = admin'\n    printf 'password = %s\\n' \"$SAB_ADMIN_PASSWORD\"\n    printf 'api_key = %s\\n' \"$SAB_API_KEY\"\n    printf '%s\\n' 'inet_exposure = 5'\n    printf 'host_whitelist = %s, sabnzbd, localhost, 127.0.0.1\\n' \"$SAB_PUBLIC_HOST\"\n    printf '%s\\n' 'download_dir = /incomplete-downloads'\n    printf '%s\\n' 'complete_dir = /downloads'\n    printf '%s\\n' 'check_new_rel = 0'\n    printf '%s\\n' 'auto_browser = 0'\n  } > \"$CONF\"\n  chmod 600 \"$CONF\"\nfi\nexec /init\n"]
null

## the image's own init, as the image carries it:
ci-service-check
init-adduser
init-config
init-config-end
init-crontab-config
init-custom-files
init-device-perms
init-envfile
init-migrations
init-mods
init-mods-end
init-mods-package-install
init-os-end
init-sabnzbd-config
init-services
svc-cron
svc-sabnzbd
user
user2
---
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
    if grep -qe ' /downloads ' /proc/mounts; then
        lsiown abc:abc /downloads
    fi

    if grep -qe ' /incomplete-downloads ' /proc/mounts; then
        lsiown abc:abc /incomplete-downloads
    fi

    find /config -path /config/Downloads -prune -o -exec lsiown abc:abc {} +
fi
---
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

FAMILY=::

if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
    if ! test -f /proc/net/if_inet6; then
        FAMILY=0.0.0.0
        sed '/ip6-/d' /etc/hosts > /etc/hosts.new
        cat /etc/hosts.new > /etc/hosts
        rm /etc/hosts.new
    fi

    exec \
        s6-notifyoncheck -d -n 300 -w 1000 \
            s6-setuidgid abc python3 /app/sabnzbd/SABnzbd.py \
            --config-file /config --server "$FAMILY"
else
    exec \
        s6-notifyoncheck -d -n 300 -w 1000 \
            python3 /app/sabnzbd/SABnzbd.py \
            --config-file /config --server "$FAMILY"
fi
