#!/bin/bash # # script: WOL_action # # Startup script for unraidwold # # Simon Fairweather - Initial Script October 2023 DAEMON="unraidwold" BINARY="/usr/local/sbin/unraidwold" # run & log functions . /etc/rc.d/rc.runlog . /boot/config/wol.cfg unraidwold_running(){ sleep 0.1 ps axc | grep -q ' unraidwold' } unraidwold_start(){ log "Starting $DAEMON..." local REPLY if unraidwold_running; then REPLY="Already started" else nohup $BINARY $1 $2 $3 $4 $5 $6 > /dev/null & fi log "$DAEMON... $REPLY." } unraidwold_stop(){ log "Stopping $DAEMON..." local REPLY if ! unraidwold_running; then REPLY="Already stopped" else killall -TERM $DAEMON if ! unraidwold_running; then REPLY="Stopped"; else REPLY="Failed"; fi fi log "$DAEMON... $REPLY." } unraidwold_status(){ if unraidwold_running; then echo "$DAEMON is currently running." else echo "$DAEMON is not running." exit 1 fi } unraidwold_load() { if unraidwold_running; then unraidwold_stop fi sleep 1 if [ "$WOLENABLED" == "yes" ]; then interfacemode="" logoptions="" if [ "$IFMODE" == "y" ]; then interfacemode="--promiscuous" fi if [ "$LOGFILE" != "syslog" ]; then logoptions="--log $LOGFILE" fi unraidwold_start --interface $INTERFACE $interfacemode $logoptions fi } case "$1" in 'start') unraidwold_start $2 $3 $4 $5 $6 ;; 'stop') unraidwold_stop ;; 'status') unraidwold_status ;; 'load') unraidwold_load ;; *) echo "Usage: $BDAEMON start|stop|restart|status" exit 1 esac exit 0