2018-06-02 11:44:55 +03:00
|
|
|
#!/bin/sh -e
|
2020-05-12 19:04:57 +03:00
|
|
|
# This script launches rv on a pi, intended to run at boot time.
|
2018-06-02 11:44:55 +03:00
|
|
|
|
2020-03-23 13:22:12 +03:00
|
|
|
RVPATH=/home/pi/go/src/bitbucket.org/ausocean/av/cmd/rv
|
2018-06-02 11:44:55 +03:00
|
|
|
|
2018-06-24 15:31:32 +03:00
|
|
|
echo Set kernel parameters:
|
2018-06-02 11:44:55 +03:00
|
|
|
# kernel settings to improve performance on Raspberry Pi
|
|
|
|
# tell Linux to fork optimistically
|
|
|
|
sudo sysctl -w vm.overcommit_memory=1
|
|
|
|
# minimize swapping, without disabling it completely
|
|
|
|
sudo sysctl -w vm.swappiness=1
|
|
|
|
|
|
|
|
# the following required directories _should_ already exist
|
|
|
|
if [ ! -d /var/log/netsender ]; then
|
|
|
|
sudo mkdir /var/log/netsender
|
|
|
|
chmod guo+rwx /var/log/netsender
|
|
|
|
fi
|
|
|
|
if [ ! -d /var/netsender ]; then
|
|
|
|
sudo mkdir /var/netsender
|
|
|
|
chmod guo+rwx /var/netsender
|
|
|
|
fi
|
|
|
|
|
2018-06-23 09:05:53 +03:00
|
|
|
# show IP addresses
|
2018-06-24 15:31:32 +03:00
|
|
|
echo Our IP addresses:
|
2018-06-23 09:05:53 +03:00
|
|
|
sudo ip addr show | grep inet
|
|
|
|
|
2018-06-02 11:44:55 +03:00
|
|
|
# capture stdout and stderr to a secondary log file (just in case)
|
|
|
|
exec 2> /var/log/netsender/stream.log
|
|
|
|
exec 1>&2
|
|
|
|
|
2020-03-23 13:22:12 +03:00
|
|
|
# set env, working dir and run rv as pi user
|
2018-08-21 08:31:16 +03:00
|
|
|
HOME=/home/pi
|
|
|
|
GOPATH=$HOME/go
|
2020-03-23 13:22:12 +03:00
|
|
|
RVPATH=$GOPATH/src/bitbucket.org/ausocean/av/cmd/rv
|
|
|
|
PATH=$PATH:/usr/local/go/bin:$RVPATH
|
|
|
|
cd $RVPATH
|
2020-05-16 17:18:11 +03:00
|
|
|
sudo -u pi HOME=$HOME GOPATH=$GOPATH PATH=$PATH ./rv
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "Successfully exited rv"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "rv exited with code: $?" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|