Potentially helpful instructions for setting up fishnet to start automatically
sAlexander opened this issue · 2 comments
sAlexander commented
Hi niklasf,
Thank you for your work on fishnet! I appreciate all the energy you put into the project.
I just finished setting up fishnet on my computer, and I wanted to share the instructions that I used in case they're helpful for others. I run Ubuntu 20.04.2 LTS, but I would expect the instructions to work for computer with systemd.
Feel free to ignore/close this issue if the instructions are too specific to my system or not generally useful; you know the fishnet users better than I do!
# Create a fishnet user. The user is created as a sysytem user
# meaning that they will not show up on your log-in screen.
sudo adduser \
--system \
--shell /bin/bash \
--gecos ‘User for running fishnet’ \
--group \
--disabled-password \
--home /home/fishnet \
fishnet
# Log in as the fishnet user.
sudo -s -u fishnet
# Download the latest fishnet to /home/fishnet.
wget {LATEST FROM https://github.com/niklasf/fishnet/releases}
# Run fishnet once to create the configuration file.
/home/fishnet/fishnet-x86_64-unknown-linux-gnu --auto-update
#
# Exit out of the fishnet user with ctrl-D
#
# Create a fishnet service in systemd.
# Once enabled, the service will run fishnet when the
# system boots. If fishnet fails for some reason, it will
# attempt to restart fishnet up to 5 times.
sudo bash -c "cat >> /etc/systemd/system/fishnet.service" << EOL
[Unit]
Description=Run fishnet
DefaultDependencies=no
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Type=simple
User=fishnet
Group=fishnet
WorkingDirectory=/home/fishnet
ExecStart=/home/fishnet/fishnet-x86_64-unknown-linux-gnu --auto-update
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=default.target
EOL
# Test out the service by starting it (one-off).
systemctl start fishnet
# Read the logs to ensure that fishnet started correctly.
journalctl -u fishnet
# Enable the fishnet service. Fishnet will start automatically on boot.
systemctl enable fishnet
#
# Disabling / removing the service.
#
# These instructions are for eventually disabling the fishnet service.
# Disable the service.
systemctl disable fishnet
niklasf commented
Hi, thanks. Check out sudo -u fishnet /home/fishnet/fishnet-x86_64-unknown-linux-gnu systemd --auto-update
. It has some improvements for your service file.
sAlexander commented
That's great, thank you!