[Unit]
Description=Ginxsom Blossom Server
Documentation=https://github.com/hzrd149/blossom
After=network.target n-os-tr-firstboot.service
Requires=n-os-tr-firstboot.service
ConditionPathExists=/var/lib/n-os-tr/env

[Service]
Type=forking
User=www-data
Group=www-data
# Provides /run/ginxsom/, cleaned up on service stop
RuntimeDirectory=ginxsom
RuntimeDirectoryMode=0755
EnvironmentFile=/var/lib/n-os-tr/env
ExecStartPre=/bin/rm -f /run/ginxsom/ginxsom-fcgi.sock
ExecStart=/usr/bin/spawn-fcgi \
    -s /run/ginxsom/ginxsom-fcgi.sock \
    -M 0660 \
    -u www-data \
    -g www-data \
    -d /var/lib/ginxsom \
    -- /usr/local/bin/ginxsom/ginxsom-fcgi \
       --admin-pubkey ${GINXSOM_ADMIN_PUBKEY} \
       --server-privkey ${GINXSOM_SERVER_PRIVKEY} \
       --db-path /var/lib/ginxsom \
       --storage-dir /var/www/blobs
ExecStop=/usr/bin/pkill -f ginxsom-fcgi
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
