Skip to content

Instantly share code, notes, and snippets.

@itguy51
Created July 27, 2013 02:58
Show Gist options
  • Save itguy51/6093485 to your computer and use it in GitHub Desktop.
Save itguy51/6093485 to your computer and use it in GitHub Desktop.
RasPi Management in a Network Cluster. Set BASEPATH_RELATIVE to a NFS/FTP/SMB mount location that is writable by the Pi and run ./app.sh to initialize. Put an app in the folder named your Pi's ID (This app runs the install.sh file in that folder) and run ./app.sh again. it should spin up whatever's in that folder.
#!/bin/sh
BASEPATH_RELATIVE=~/roms/apps/
echo "System ID is"
grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo
if [ -d $BASEPATH_RELATIVE`grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo` ]; then
echo "App Folder Found. Checking for install script"
cd $BASEPATH_RELATIVE`grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo`
if [ -e install.sh ]; then
echo "Install Script found. Chmodding+Executing."
chmod +x install.sh
sh install.sh
else
echo "Install Script not Found. Abort."
fi
else
echo "No App Folder Found. Creating then Abort."
mkdir $BASEPATH_RELATIVE`grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment