CiscoSecurity / fp-05-firepower-cli

Public Repo for an eStreamer CLI project
10 stars 8 forks source link

systemd service to start estreamer on boot rootless #25

Closed Macleykun closed 5 months ago

Macleykun commented 5 months ago

I'm not sure if this repo accept's pulls or that issues are reviewed/handeld. So i'll just drop the steps i did to make this script run in the background for anyone who happen to look for that.

  1. Make a rootless user and clone the files you need in it's home directory.
  2. Allow the user to linger so it can background processes: sudo loginctl enable-linger rootlessusername
  3. Add this line into the .bashrc file of the user: export XDG_RUNTIME_DIR=/run/user/$UID . That way if you su - rootlessusername you can interract with the service unit as a user.
  4. Make the needed directory: mkdir -p ~/.config/systemd/user
  5. Make the service file, replace the path with the path of where the script is!

cat .config/systemd/user/estreamer.service

[Unit]
Description=eStreamer eNcore

[Service]
Type=simple
StandardOutput=journal
WorkingDirectory=/home/rootlessusername/fp-05-firepower-cli
ExecStart=/home/rootlessusername/fp-05-firepower-cli/encore.sh foreground

[Install]
WantedBy=default.target
  1. reload the systemd deamon so you can interract with the service: systemctl --user deamon-reload
  2. Verify you can interract with it: systemctl --user stat estreamer.service
  3. Start and enable it: systemctl --user enable --now estreamer.service

This has been tested. If you do use this service make sure to stop it if you interract with the script through the terminal!