Start on boot
Linux
On most Linux distributions (including Ubuntu and Debian, but not OpenWrt), systemd is in charge of managing services and starting them on boot.
Move the server executable and configuration in global folders:
sudo mv krznlive /usr/local/bin/
sudo mv krznlive.yml /usr/local/etc/
Create a systemd service:
sudo tee /etc/systemd/system/krznlive.service >/dev/null << EOF
[Unit]
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/krznlive /usr/local/etc/krznlive.yml
[Install]
WantedBy=multi-user.target
EOF
Enable a wait-online service to make sure that KRZN Live is started after network has been properly initialized:
sudo systemctl enable systemd-networkd-wait-online.service
If SELinux is enabled (for instance in case of RedHat, Rocky, CentOS++), add correct security context:
semanage fcontext -a -t bin_t /usr/local/bin/krznlive
restorecon -Fv /usr/local/bin/krznlive
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable krznlive
sudo systemctl start krznlive
OpenWrt
Move the server executable and configuration in global folders:
mv krznlive /usr/bin/
mkdir -p /usr/etc && mv krznlive.yml /usr/etc/
Create a procd service:
tee /etc/init.d/krznlive >/dev/null << EOF
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01
start_service() {
procd_open_instance
procd_set_param command /usr/bin/krznlive
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
EOF
Enable and start the service:
chmod +x /etc/init.d/krznlive
/etc/init.d/krznlive enable
/etc/init.d/krznlive start
Read the server logs:
logread
Windows
Download the WinSW v2 executable and place it into the same folder of krznlive.exe.
In the same folder, create a file named WinSW-x64.xml with this content:
<service>
<id>krznlive</id>
<name>krznlive</name>
<description></description>
<executable>%BASE%/krznlive.exe</executable>
</service>
Open a terminal, navigate to the folder and run:
WinSW-x64 install
The server is now installed as a system service and will start at boot time.