├── README.md ├── pi_post_setup.sh ├── pi_setup.sh ├── rc.local ├── set_gpu.sh └── startsph /README.md: -------------------------------------------------------------------------------- 1 | TinySetup 2 | ========= 3 | 4 | TinySetup can be used to setup a new TinyTitan unit in just a few steps. 5 | 6 | ## Step One 7 | Step one will update each Raspberry Pi and configure the name and network settings. To start connect each Pi that will be part of the TinyTitan cluster to an active internet connection. Download the initial setup script and run it in a terminal as such: 8 | 9 | ``` 10 | $ curl -kfsSLO https://raw.github.com/TinyTitan/TinySetup/master/pi_setup.sh 11 | $ bash pi_setup.sh 12 | ``` 13 | 14 | When prompted for the node number start at 1 and incriment to the total number of Raspberry Pi nodes. 15 | 16 | ## Step Two 17 | With step one completed on all nodes connect each node to the router or switch. On the Pi that was given a node number of 1 login and download/run the second script: 18 | 19 | ``` 20 | $ git clone https://github.com/TinyTitan/TinySetup.git 21 | $ cd TinySetup 22 | $ bash pi_post_setup.sh 23 | ``` 24 | 25 | ## Step Three 26 | Your TinyTitan unit should now be ready to go. Checkout the TinySPH and PiBrot examples available through the TinyTitan repo. 27 | -------------------------------------------------------------------------------- /pi_post_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #The MIT License (MIT) 4 | 5 | #Copyright (c) 2014 Oak Ridge National Laboratory 6 | 7 | #Permission is hereby granted, free of charge, to any person obtaining a copy 8 | #of this software and associated documentation files (the "Software"), to deal 9 | #in the Software without restriction, including without limitation the rights 10 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | #copies of the Software, and to permit persons to whom the Software is 12 | #furnished to do so, subject to the following conditions: 13 | 14 | #The above copyright notice and this permission notice shall be included in 15 | #all copies or substantial portions of the Software. 16 | 17 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | #THE SOFTWARE. 24 | 25 | echo "Enter the total number of Pi nodes in the cluster followed by [ENTER]: " 26 | read num_pis 27 | re='^[0-9]+$' 28 | if ! [[ $num_pis =~ $re ]] ; then 29 | echo "Error: Please enter integer" >&2; exit 1 30 | fi 31 | 32 | echo "Removing ~/mpihostsfile" 33 | rm -f ~/mpihostsfile 34 | echo "Removing ~/.ssh/authorized_keys" 35 | rm -f ~/.ssh/authorized_keys 36 | 37 | echo "Generating ~/mpihostsfile" 38 | echo "Generating ~/.ssh/authorized_keys" 39 | echo "Updating /etc/hosts" 40 | 41 | sudo sed -i '/192.168.3.*/d' /etc/hosts 42 | 43 | for (( i=1; i<=$num_pis; i++ )) 44 | do 45 | num=$(($i+100)) 46 | ip=192.168.3.$num 47 | echo $ip >> ~/mpihostsfile 48 | sudo sh -c "echo \"$ip pi$i\" >> /etc/hosts" 49 | sshpass -p 'raspberry' scp -o StrictHostKeyChecking=no pi@pi$i:~/.ssh/id_rsa.pub tmp_key 50 | cat tmp_key >> ~/.ssh/authorized_keys 51 | done 52 | 53 | for (( i=1; i<=$num_pis; i++ )) 54 | do 55 | sshpass -p 'raspberry' scp -o StrictHostKeyChecking=no ~/.ssh/authorized_keys pi@pi$i:~/.ssh/authorized_keys 56 | done 57 | 58 | sudo rm tmp_key 59 | 60 | echo "Setting GPU memory to 128MB" 61 | sudo bash ./set_gpu.sh 62 | 63 | echo "Rebooting" 64 | sudo reboot 65 | -------------------------------------------------------------------------------- /pi_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #The MIT License (MIT) 4 | 5 | #Copyright (c) 2014 Oak Ridge National Laboratory 6 | 7 | #Permission is hereby granted, free of charge, to any person obtaining a copy 8 | #of this software and associated documentation files (the "Software"), to deal 9 | #in the Software without restriction, including without limitation the rights 10 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | #copies of the Software, and to permit persons to whom the Software is 12 | #furnished to do so, subject to the following conditions: 13 | 14 | #The above copyright notice and this permission notice shall be included in 15 | #all copies or substantial portions of the Software. 16 | 17 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | #THE SOFTWARE. 24 | 25 | 26 | echo "Enter the node number of this pi followed by [ENTER]: " 27 | read pi_number 28 | re='^[0-9]+$' 29 | if ! [[ $pi_number =~ $re ]] ; then 30 | echo "Error: Please enter integer" >&2; exit 1 31 | fi 32 | pi_name="pi$pi_number" 33 | 34 | echo "Installing system software and updates" 35 | sudo apt-get -y update 36 | sudo apt-get -y upgrade 37 | sudo apt-get -y install vim mpich2 xboxdrv libglew-dev sshpass libav-tools 38 | 39 | echo "Setting computer name" 40 | for file in \ 41 | /etc/hosts \ 42 | /etc/hostname \ 43 | /etc/ssh/ssh_host_rsa_key.pub \ 44 | /etc/ssh/ssh_host_dsa_key.pub 45 | do 46 | [ -f $file ] && sudo sed -i -E "s/pi[0-9]+/$pi_name/" $file > /dev/null 2>&1 47 | [ -f $file ] && sudo sed -i "s/raspberrypi/$pi_name/" $file > /dev/null 2>&1 48 | done 49 | sudo /etc/init.d/hostname.sh start > /dev/null 2>&1 50 | sudo hostname $pi_name 51 | 52 | echo "Setting network interface" 53 | sudo tee /etc/network/interfaces <<-EOF 54 | auto lo 55 | 56 | iface lo inet loopback 57 | # iface eth0 inet dhcp 58 | 59 | auto eth0 60 | iface eth0 inet static 61 | address 192.168.3.$(($pi_number+100)) 62 | gateway 192.168.3.1 63 | netmask 255.255.255.0 64 | network 192.168.3.0 65 | broadcast 192.168.3.255 66 | 67 | # allow-hotplug wlan0 68 | # iface wlan0 inet manual 69 | # wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf 70 | # iface default inet dhcp 71 | EOF 72 | 73 | echo "Generating key-pairs" 74 | ssh-keygen -N '' -f /home/pi/.ssh/id_rsa 75 | 76 | echo "Rebooting" 77 | sudo reboot 78 | -------------------------------------------------------------------------------- /rc.local: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # rc.local 4 | # 5 | # This script is executed at the end of each multiuser runlevel. 6 | # Make sure that the script will "exit 0" on success or any other 7 | # value on error. 8 | # 9 | # In order to enable or disable this script just change the execution 10 | # bits. 11 | # 12 | # By default this script does nothing. 13 | 14 | # Print the IP address 15 | _IP=$(hostname -I) || true 16 | if [ "$_IP" ]; then 17 | printf "My IP address is %s\n" "$_IP" 18 | fi 19 | 20 | sudo rmmod xpad 21 | sudo xboxdrv --mouse --wid 0 --led 2 --config /home/pi/SPH/controller_1.cnf --silent & 22 | sleep 1 23 | sudo xboxdrv --mouse --wid 1 --led 3 --config /home/pi/SPH/controller_2.cnf --silent & 24 | sleep 1 25 | 26 | sudo rm -f /home/pi/running /home/pi/script_running 27 | 28 | exit 0 29 | -------------------------------------------------------------------------------- /set_gpu.sh: -------------------------------------------------------------------------------- 1 | ##################################################### 2 | 3 | #Copyright (c) 2012 Alex Bradbury 4 | 5 | #Permission is hereby granted, free of charge, to any person 6 | #obtaining a copy of this software and associated documentation 7 | #files (the "Software"), to deal in the Software without 8 | #restriction, including without limitation the rights to use, 9 | #copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | #copies of the Software, and to permit persons to whom the 11 | #Software is furnished to do so, subject to the following 12 | #conditions: 13 | 14 | #The above copyright notice and this permission notice shall be 15 | #included in all copies or substantial portions of the Software. 16 | 17 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | #OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | set_config_var() { 27 | lua - "$1" "$2" "$3" < "$3.bak" 28 | local key=assert(arg[1]) 29 | local value=assert(arg[2]) 30 | local fn=assert(arg[3]) 31 | local file=assert(io.open(fn)) 32 | local made_change=false 33 | for line in file:lines() do 34 | if line:match("^#?%s*"..key.."=.*$") then 35 | line=key.."="..value 36 | made_change=true 37 | end 38 | print(line) 39 | end 40 | 41 | if not made_change then 42 | print(key.."="..value) 43 | end 44 | EOF 45 | mv "$3.bak" "$3" 46 | } 47 | 48 | set_config_var gpu_mem "128" /boot/config.txt 49 | -------------------------------------------------------------------------------- /startsph: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f /home/pi/script_running ] 4 | then 5 | touch /home/pi/script_running 6 | else 7 | echo "kiosk script_running already exists" 8 | exit 1 9 | fi 10 | 11 | start_sph() { 12 | if [ ! -f /home/pi/running ] 13 | then 14 | touch /home/pi/running 15 | echo 16 | echo "Starting SPH" 17 | cd /home/pi && su pi -c 'mpirun -f /home/pi/pi_mpihostsfile -n 9 /home/pi/sph.out' 18 | EXITCODE=$? 19 | rm -f /home/pi/running 20 | #clear 21 | echo 22 | echo "SPH Done" 23 | 24 | else 25 | echo 26 | echo "Already running either SPH or PiBrot, /home/pi/running exists" 27 | fi 28 | } 29 | 30 | start_pibrot() { 31 | if [ ! -f /home/pi/running ] 32 | then 33 | touch /home/pi/running 34 | echo 35 | echo "Starting PiBrot" 36 | cd /home/pi && su pi -c 'mpirun -f /home/pi/pi_mpihostsfile -n 9 /home/pi/pibrot' 37 | EXITCODE=$? 38 | rm -f /home/pi/running 39 | #clear 40 | echo 41 | echo "PiBrot Done" 42 | 43 | else 44 | echo 45 | echo "Already running either SPH or PiBrot, /home/pi/running exists" 46 | fi 47 | } 48 | 49 | EXITCODE=20 50 | 51 | while true 52 | do 53 | sleep 1 54 | case "$EXITCODE" in 55 | 20) 56 | start_sph 57 | ;; 58 | 10) 59 | start_pibrot 60 | ;; 61 | *) 62 | echo "All Done! Last EXITCODE:" $EXITCODE 63 | rm -f /home/pi/script_running 64 | exit 1 65 | esac 66 | done 67 | --------------------------------------------------------------------------------