NetBSD 10.x / 11.x, amd64 / i386
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 script 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.Write a self-contained rc.d script with explicit start/stop/status commands — NetBSD has no built-in supervisor, so pidfile bookkeeping is handled here. 555 permissions let root execute it without accidental writes.
sudo tee /etc/rc.d/trigger_cl > /dev/null <<'EOF'
#!/bin/sh
#
# PROVIDE: trigger_cl
# REQUIRE: NETWORKING
# KEYWORD: shutdown
$_rc_subr_loaded . /etc/rc.subr
name="trigger_cl"
rcvar=${name}
pidfile="/var/run/${name}.pid"
logfile="/var/log/${name}.log"
: ${trigger_cl_dir:="/opt/trigger_cl"}
command="${trigger_cl_dir}/trigger_cl"
start_cmd="trigger_cl_start"
stop_cmd="trigger_cl_stop"
status_cmd="trigger_cl_status"
trigger_cl_start() {
if [ -f "$pidfile" ] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then
echo "${name} already running as pid $(cat "$pidfile")."
return 1
fi
echo "Starting ${name}."
( "$command" >> "$logfile" 2>&1 ) &
echo $! > "$pidfile"
}
trigger_cl_stop() {
if [ ! -f "$pidfile" ]; then
echo "${name} not running."
return 1
fi
pid=$(cat "$pidfile")
echo "Stopping ${name} (pid $pid)."
kill "$pid" 2>/dev/null || true
rm -f "$pidfile"
}
trigger_cl_status() {
if [ -f "$pidfile" ] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then
echo "${name} is running as pid $(cat "$pidfile")."
return 0
fi
echo "${name} is not running."
return 1
}
load_rc_config $name
run_rc_command "$1"
EOF
sudo chmod 555 /etc/rc.d/trigger_cl
NetBSD toggles rc services via /etc/rc.conf (no rcctl or sysrc). Append the enable line, then start the service in place.
echo 'trigger_cl=YES' | sudo tee -a /etc/rc.conf
sudo /etc/rc.d/trigger_cl start
The status subcommand checks the pidfile and reports back. The log file captures all stdout and stderr while the daemon runs.
sudo /etc/rc.d/trigger_cl status
sudo tail -f /var/log/trigger_cl.log
trigger_cl ever exits, you’ll have to restart it
manually. The client itself auto-reconnects on TCP drops, so crashes
are rare — but if you need hard supervision, wrap it in
daemontools from pkgsrc.