Skip to content

Instantly share code, notes, and snippets.

@pandrewhk
Created December 6, 2015 19:43
Show Gist options
  • Save pandrewhk/642531a9040b46c0bc5a to your computer and use it in GitHub Desktop.
Save pandrewhk/642531a9040b46c0bc5a to your computer and use it in GitHub Desktop.
#!/bin/sh
# PROVIDE: digitalocean
# REQUIRE: var
# BEFORE: netif hostname
. /etc/rc.subr
name="digitalocean"
start_cmd="${name}_start"
stop_cmd=":"
digitalocean_start()
{
check_startmsgs && echo "Generating DigitalOcean configuration."
/usr/local/sbin/avahi-autoipd -c vtnet0
if [ $? != 0 ]
then
/usr/local/sbin/avahi-autoipd --force-bind -w -D vtnet0
DROPLET_ID=$(/usr/local/bin/curl --retry 5 --retry-delay 2 --connect-timeout 2 -s http://169.254.169.254/metadata/v1/id)
if [ -e /etc/rc.digitalocean.d/$DROPLET_ID.conf ]
then
/bin/ln -s -f /etc/rc.digitalocean.d/$DROPLET_ID.conf /etc/rc.digitalocean.d/droplet.conf
else
/usr/local/bin/python2.7 /usr/local/bsd-cloudinit/run.py --log-file /var/log/bsd-cloudinit.log
/bin/ln -s -f /etc/rc.digitalocean.d/$DROPLET_ID.conf /etc/rc.digitalocean.d/droplet.conf
fi
fi
}
load_rc_config $name
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment