Start dashboard (Linux docker image) by means of systemd

Hi team,

I want to start the dashboard using systemd, but this scenario fails

[Unit]
Description=Crowdsec Dashboard
Documentation=https://docs.crowdsec.net/docs/observability/dashboard
Wants=network-online.target docker.service crowdsec.service
After=network-online.target docker.service crowdsec.service

[Service]
Type=simple
ExecStart=cscli dashboard start
ExecStop=cscli dashboard stop

[Install]
WantedBy=multi-user.target

The cause seems to be that “cscli dashboard start” expects a “Return” after start “CrowdSec takes no responsibility for the security of your metabase instance. Do you accept these responsibilities ? (Y/n)”

So I changed to

[Unit]
Description=Crowdsec Dashboard
Documentation=https://docs.crowdsec.net/docs/observability/dashboard
Wants=network-online.target docker.service crowdsec.service
After=network-online.target docker.service crowdsec.service

[Service]
Type=simple
ExecStart=cscli_dashboard_start
ExecStop=cscli dashboard stop

[Install]
WantedBy=multi-user.target

The start command looks like this

#!/usr/bin/env expect
spawn "cscli" dashboard start
expect "CrowdSec takes no responsibility for the security of your metabase instance. Do you accept these responsibilities ?" { send "\r" }
interact

Unfortunately this does not work either,

can you please verify, and best of all give a solution for this problem?

Martin.

Within the start documentation we provide a force yes flag to accept all of these

Ah, this was quick - thank you!

This is a very valuable information, since the command

“cscli dashboard --help”

does not show that this flag exists.

Martin.

“cscli dashboard --help”

No because you need to do cscli dashboard setup --help each subcommand has it own set of flags

Error on user side (me), should have read better…

But, although I force with the “–yes” flag, the dashboard does not get started.
Will try to figure why…

Martin.

Well, finally I managed…

this is the updated systemd file, and this works well!

[Unit]
Description=Crowdsec Dashboard
Documentation=https://docs.crowdsec.net/docs/observability/dashboard
Wants=network-online.target docker.service crowdsec.service
After=network-online.target docker.service crowdsec.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart="/usr/bin/cscli" dashboard start --yes
ExecStop="/usr/bin/cscli" dashboard stop

[Install]
WantedBy=multi-user.target