Skip to content

Instantly share code, notes, and snippets.

@rcreasey
Created August 11, 2010 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcreasey/412f9588c4c60341108f to your computer and use it in GitHub Desktop.
Save rcreasey/412f9588c4c60341108f to your computer and use it in GitHub Desktop.
#!/bin/sh
NAME=`/bin/hostname -s`
waitress_url="http://X.X.10.39"
base_url="http://X.X.7.17/chef"
mkdir -p /export/skynet
# Assume that this is looking for a json based off a MAC hostname
/usr/bin/wget -q $waitress_url/${NAME} -O /export/skynet/${NAME}.json
if [ -s /export/skynet/${NAME}.json ]; then
/usr/bin/wget -q $base_url/solo.rb -O /export/skynet/solo.rb
/usr/bin/chef-solo -L /export/skynet/scaffold.log -c /export/skynet/solo.rb -j /export/skynet/${NAME}.json -r $base_url/bootstrap.tgz
/usr/bin/chef-client >/dev/null 2>&1
/sbin/shutdown -h now
else
# Lets see if this host has an explicit definition
NAME=`/bin/hostname | /bin/cut -d. -f1,2`
/usr/bin/wget -q $base_url/nodes/${NAME}.json -O /export/skynet/${NAME}.json
if [ -s /export/skynet/${NAME}.json ]; then
/usr/bin/wget -q $base_url/solo.rb -O /export/skynet/solo.rb
/usr/bin/chef-solo -L /export/skynet/scaffold.log -c /export/skynet/solo.rb -j /export/skynet/${NAME}.json -r $base_url/bootstrap.tgz
/usr/bin/chef-client >/dev/null 2>&1
/sbin/reboot
else
# This isn't the json you're looking for; abort.
rm -rf /export/skynet
echo "Unable to find bootstrap json. Please try again."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment