mirror of https://bitbucket.org/ausocean/av.git
treat: makefile, service and .sh scripts for installing
This commit is contained in:
parent
96a3b130b8
commit
45e36a6c09
|
@ -89,7 +89,7 @@ func main() {
|
|||
mts.Meta = meta.NewWith([][2]string{{metaPreambleKey, metaPreambleData}})
|
||||
|
||||
// Set up the player command with audio file path.
|
||||
filePtr := flag.String("path", "", "Path to sound file we wish to play.")
|
||||
filePtr := flag.String("path", "~/audio.wav", "Path to sound file we wish to play.")
|
||||
flag.Parse()
|
||||
|
||||
// Create lumberjack logger to handle logging to file.
|
||||
|
|
|
@ -25,6 +25,9 @@ install: as_root make_dirs soft_copy_files
|
|||
install_hard: as_root make_dirs hard_copy_files set_mac syncreboot
|
||||
@echo "Hard install complete"
|
||||
|
||||
install_hard_treat: as_root make_dirs hard_copy_files_treat set_mac syncreboot
|
||||
@echo "Hard install complete"
|
||||
|
||||
as_root:
|
||||
ifneq ($(USER),root)
|
||||
$(error Must run as superuser!)
|
||||
|
@ -69,6 +72,20 @@ hard_copy_files:
|
|||
printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf
|
||||
chown pi /etc/netsender.conf
|
||||
|
||||
hard_copy_files_treat:
|
||||
if [ -f /etc/systemd/system/treatment.service ] ; then \
|
||||
echo "/etc/systemd/system/treatment.service overwritten" ; \
|
||||
fi
|
||||
cp -f treatment.service /etc/systemd/system
|
||||
systemctl enable treatment.service
|
||||
chmod +x pi_run.sh
|
||||
if [ -f /etc/netsender.conf ] ; then \
|
||||
echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \
|
||||
cp /etc/netsender.conf /etc/netsender.conf.bak ; \
|
||||
fi
|
||||
printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf
|
||||
chown pi /etc/netsender.conf
|
||||
|
||||
set_mac:
|
||||
printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook
|
||||
chmod guo+x /etc/dhcpcd.enter-hook
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Netsender Client for Playing and Recording Sound
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/pi/go/src/bitbucket.org/ausocean/av/init/treatment_run.sh
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh -e
|
||||
# This script launches treatment on a pi, intended to run at boot time.
|
||||
|
||||
TREATPATH=/home/pi/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 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
|
||||
|
||||
# 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 pi user
|
||||
HOME=/home/pi
|
||||
GOPATH=$HOME/go
|
||||
TREATPATH=$GOPATH/src/bitbucket.org/ausocean/av/cmd/treatment
|
||||
PATH=$PATH:/usr/local/go/bin:$TREATPATH
|
||||
cd $TREATPATH
|
||||
sudo -u pi HOME=$HOME GOPATH=$GOPATH PATH=$PATH ./treatment
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Successfully exited treatment"
|
||||
exit 0
|
||||
else
|
||||
echo "treatment exited with code: $?" >&2
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue