mirror of https://bitbucket.org/ausocean/av.git
46 lines
1.2 KiB
Bash
Executable File
46 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -e
|
|
# This script launches rv on a <user>, intended to run at boot time.
|
|
|
|
RVPATH=/home/<user>/go/src/bitbucket.org/ausocean/av/cmd/rv
|
|
|
|
echo Set kernel parameters:
|
|
# kernel settings to improve performance on Raspberry Pi
|
|
# tell Linux to fork optimistically
|
|
sudo sysctl -w vm.overcommit_memory=1
|
|
# minimize swap<user>ng, 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
|
|
|
|
# show IP addresses
|
|
echo Our IP addresses:
|
|
sudo ip addr show | grep inet
|
|
|
|
# capture stdout and stderr to a secondary log file (just in case)
|
|
exec 2> /var/log/netsender/stream.log
|
|
exec 1>&2
|
|
|
|
# set env, working dir and run rv as <user> user
|
|
HOME=/home/<user>
|
|
GOPATH=$HOME/go
|
|
RVPATH=$GOPATH/src/bitbucket.org/ausocean/av/cmd/rv
|
|
PATH=$PATH:/usr/local/go/bin:$RVPATH
|
|
cd $RVPATH
|
|
sudo -u <user> 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
|