Add notes / rc file for FreeBSD

addresses #229
This commit is contained in:
Jan-Piet Mens
2018-04-23 20:25:49 +02:00
parent 21df648b8e
commit 064ff8d64a
2 changed files with 55 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: otrecorder
# REQUIRE: LOGIN mosquitto hass
# KEYWORD: shutdown
#
. /etc/rc.subr
name=otrecorder
rcvar=${name}_enable
start_cmd=${name}_start
stop_cmd=${name}_stop
load_rc_config $name
: ${otrecorder_enable:=NO}
: ${otrecorder_pidfile:=/var/run/otrecorder.pid}
command=/usr/local/sbin/ot-recorder
#command_args="--debug --norevgeo"
command_args="--debug --label MyMap"
otrecorder_start()
{
if [ -f $otrecorder_pidfile ] && kill -0 $(cat $otrecorder_pidfile) >/dev/null 2>&1 ; then
echo 'Service already running'
return 1
fi
echo 'Starting service after 10 secs so mosquitto is up'
sleep 10;
$command $command_args &
echo $! > ${otrecorder_pidfile}
echo 'Service started'
}
otrecorder_stop()
{
if [ ! -f $otrecorder_pidfile ] || ! kill -0 $(cat $otrecorder_pidfile) >/dev/null 2>&1 ; then
echo 'Service not running'
return 1
fi
echo 'Stopping service'
kill $(cat $otrecorder_pidfile)
while ps -p $(cat $otrecorder_pidfile) >/dev/null 2>&1 ; do sleep 1;done
echo 'Service stopped'
}
run_rc_command "$1"
+6
View File
@@ -0,0 +1,6 @@
- must use gmake
- place script in /usr/local/etc/rc.d/ot-recorder
- creates pid file out of $! to make restart and stop possible
- note regarding line: # REQUIRE: LOGIN mosquitto hass
remove mosquitto and hass if not setup on this box, but let LOGIN there
if mosquitto runs on same box REQUIRE is a must! hass is Home Assistant