Skip to content

Instantly share code, notes, and snippets.

@dch
Last active June 7, 2019 11:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dch/5a91afc3e7239415d4b9195fd957ac0f to your computer and use it in GitHub Desktop.
Save dch/5a91afc3e7239415d4b9195fd957ac0f to your computer and use it in GitHub Desktop.
digital ocean's automatic setup script
# /etc/rc.digitalocean.d/droplet.conf
# Generated by bsdcloud-init 2017-01-31 08:52
hostname="wolf.example.org"
# Generated by bsdcloud-init 2017-01-31 08:52
ifconfig_vtnet0_alias0="inet 10.18.0.5 netmask 255.255.0.0"
# Generated by bsdcloud-init 2017-01-31 08:52
ifconfig_vtnet0="inet 188.166.73.162 netmask 255.255.192.0"
# Generated by bsdcloud-init 2017-01-31 08:52
defaultrouter="188.166.64.1"
#!/bin/sh
# /etc/rc.d/digitalocean
# PROVIDE: digitalocean
# REQUIRE: var
# BEFORE: netif hostname
. /etc/rc.subr
name="digitalocean"
start_cmd="${name}_start"
stop_cmd=":"
digitalocean_start()
{
echo "Resizing the disk..."
/sbin/gpart recover vtbd0
/sbin/gpart resize -i 2 vtbd0
echo "Expanding the ZFS pool"
/sbin/zpool online -e zroot gpt/disk0
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