-
-
Save rcreasey/412f9588c4c60341108f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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