[Unit]
Description=@APP@ high-speed web-based traffic monitoring and analysis tool
After=@SERVICE_AFTER@
Requires=@SERVICE_REQUIRES@
Wants=@SERVICE_WANTS@
PartOf=@SERVICE_WANTS@

[Service]
Type=simple

ExecStartPre=/bin/sh -c '/usr/bin/ntopng-utils-manage-config -a check-restore  && /usr/bin/ntopng-utils-manage-config -a restore || true'
ExecStartPre=/bin/sh -c '/bin/cat /etc/ntopng/ntopng.conf > /run/ntopng.conf.raw'
ExecStartPre=/bin/sh -c '/bin/cat /etc/ntopng/ntopng.conf.d/*.conf >> /run/ntopng.conf.raw 2>/dev/null || true'
ExecStartPre=/bin/sh -c '/bin/sed "/^[ ]*-e.*$\\|^[ ]*-G.*\\|^[ ]*--daemon.*\\|[ ]*--pid.*/s/^/#/" /run/ntopng.conf.raw > /run/ntopng.conf'

ExecStart=/usr/bin/@APP@ /run/ntopng.conf

ExecStopPost=-/bin/rm -rf /run/ntopng.conf /run/ntopng.conf.raw /run/ntopng.pid

Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
Alias=@SERVICE_ALIAS@
