hello!
For a remote personal weather station I've decided to use Arch Linux on R-Pi as it's the distro which takes least space. I've never used Arch before and have a very limited Linux experience/knowledge, so far I've managed to set up pretty much everything I need without much hassle.
However, I'm really stuck with setting up the software daemon to run at boot. I read up on systemd and frankly it's just beyond my comprehension, I also googled for writing custom systemd scripts but it's all too confusing and unclear for me
This is the script I need to change:
$this->bbcode_second_pass_code('', '#!/bin/sh
# $Id: weewx.bsd 1485 2013-10-10 20:33:57Z mwall $
# Start script for FreeBSD, contributed by user Fabian Abplanalp
# Adjust app and cfg locations as appropriate, then put this script
# in /usr/local/etc/rc.d
#
WEEWX_BIN="/opt/weewx/bin/weewxd"
WEEWX_CFG="/opt/weewx/weewx.conf"
PIDFILE="/var/run/weewx.pid"
case "$1" in
"start")
echo "Starting weewx..."
/usr/local/bin/python ${WEEWX_BIN} ${WEEWX_CFG} --daemon &
echo $! > ${PIDFILE}
echo "done"
;;
"stop")
echo "Stopping weewx..."
if [ -f ${PIDFILE} ] ; then
kill `cat ${PIDFILE}`
rm ${PIDFILE}
echo "done"
else
echo "not running?"
fi
;;
"restart")
echo "Restarting weewx..."
$0 stop
sleep 2
$0 start
;;
*)
echo "$0 [start|stop|restart]"
;;
esac')
I can easily change the following paths:
WEEWX_BIN="/opt/weewx/bin/weewxd"
WEEWX_CFG="/opt/weewx/weewx.conf
/usr/local/bin/python
other than that I'm really not sure what to do. For example what would be the equivalent of "PIDFILE="/var/run/weewx.pid" ?! I've tried looking for weewx.pid when it's running on my system but it doesn't exist.
From what I gather, after fixing the shell script I'll have to:
a) create a new file: /etc/systemd/system/weewx.service with contents:
$this->bbcode_second_pass_code('', '[Unit]
Description=weewx
[Service]
ExecStart=/usr/bin/weewx
[Install]
WantedBy=multi-user.target ')
b) execute # systemctl enable weewx.service