raspberrypi/acatcher/provision_streamers.sh

30 lines
871 B
Bash
Executable file

#!/bin/bash
if [ ! -f "$1" ]; then
echo "error: must supply rooms list"
exit 1
fi
if [ -z "$2" ]; then
./mkhosts.sh "$1"
./mkacatcher_cpp.sh "$1"
fi
if [ ! -z "$2" ]; then
if grep -q "$2" "$1" ]; then
HOSTS="$2"
fi
else
HOSTS="`cat $1`"
fi
echo $HOSTS
for HOST in $HOSTS; do
>&2 echo "provisioning host $HOST"
ssh pi@$HOST "if [ ! -d \$HOME/.ssh ]; then mkdir \$HOME/.ssh; fi; echo `cat $HOME/.ssh/id_rsa.pub` >> \$HOME/.ssh/authorized_keys; chmod 700 \$HOME/.ssh; chmod 644 \$HOME/.ssh/authorized_keys"
for FILE in HOSTS SERVERIP stream.sh set_hostname.sh v4lcap.c; do scp $FILE pi@$HOST:$FILE; done
ssh pi@$HOST "sudo apt-get -y install screen"
ssh pi@$HOST "make v4lcap"
ssh pi@$HOST "cd \$HOME && bash set_hostname.sh"
ssh pi@$HOST "sudo reboot"
done
echo "all machines will require a few minutes to reboot, be patient grasshopper"