FreeBSD 14.x / 15.x, i686 / amd64
Application location: /opt/trigger_cl
Create the install directory, copy the binary and config.ini into it, and mark the executable runnable. The rc.d wrapper expects it exactly here.
sudo mkdir -p /opt/trigger_cl
sudo cp trigger_cl config.ini /opt/trigger_cl/
sudo chmod +x /opt/trigger_cl/trigger_cl
Edit config.ini and fill in the [server] section. These two lines are the only required change before first start.
sudo vi /opt/trigger_cl/config.ini
# in section [server] set
ip = trigger.itperfectservice.com
port = 9000
Export a per-host key file and print the matching key string. Both are needed to pair this machine with the mobile app.
sudo /opt/trigger_cl/trigger_cl --export-bin /opt/trigger_cl/key.bin
sudo /opt/trigger_cl/trigger_cl --show-key
Hand the key material to your phone: the binary file onto the device, the printed string into your account. From now on the phone can issue commands to this host.
key.bin to your Android device.KEY-XXXXXXXXXXXXX string — it identifies this host in the mobile UI.Create the ports-style rc.d directory if missing, drop in the script, and mark it executable. It defers to daemon(8) for process supervision, so the binary stays simple.
sudo mkdir -p /usr/local/etc/rc.d
sudo tee /usr/local/etc/rc.d/trigger_cl > /dev/null <<'EOF'
#!/bin/sh
#
# PROVIDE: trigger_cl
# REQUIRE: NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name="trigger_cl"
rcvar="trigger_cl_enable"
: ${trigger_cl_enable:="NO"}
: ${trigger_cl_dir:="/opt/trigger_cl"}
pidfile="/var/run/${name}.pid"
logfile="/var/log/${name}.log"
# daemon(8) supervises the frozen binary: -r restart on exit,
# -R 10 wait 10s between restarts, -P writes pidfile.
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -R 10 -o ${logfile} -f -- ${trigger_cl_dir}/trigger_cl"
load_rc_config $name
run_rc_command "$1"
EOF
sudo chmod 755 /usr/local/etc/rc.d/trigger_cl
sysrc writes trigger_cl_enable=YES into /etc/rc.conf so the daemon survives reboots. service(8) starts it right now through the rc.d wrapper.
sudo sysrc trigger_cl_enable=YES
sudo service trigger_cl start
service status asks the rc wrapper for the daemon state. The log file is where daemon(8) collects stdout and stderr.
sudo service trigger_cl status
sudo tail -f /var/log/trigger_cl.log
daemon(8) handles automatic restart
with a 10 second backoff — no need for an external process
manager.