Initial commit
This commit is contained in:
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Starts Lora packet forwarder
|
||||
#
|
||||
|
||||
# Allow a few customizations from a config file
|
||||
test -r /etc/default/packet-forwarder && . /etc/default/packet-forwarder
|
||||
|
||||
reset_sx1301() {
|
||||
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/export
|
||||
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction
|
||||
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "1" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/unexport
|
||||
}
|
||||
|
||||
start() {
|
||||
printf "Starting LoRa packet forwarder: "
|
||||
umask 077
|
||||
|
||||
reset_sx1301
|
||||
|
||||
cd /etc/ttn
|
||||
start-stop-daemon -S -b -q -p /var/run/packet-forwarder.pid \
|
||||
--exec /usr/bin/poly_pkt_fwd -- $PACKETFORWARDER_ARGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping LoRa packet forwarder: "
|
||||
start-stop-daemon -K -q -p /var/run/packet-forwarder.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
Reference in New Issue
Block a user