Vultr allows you to assign two types of scripts to a server. Boot scripts configure new deployments, and PXE scripts automatically install operating systems. Assign startup scripts to your servers on your Startup Scripts page.
A boot script is executed on your server the very first time it starts. It will not run on subsequent reboots.
/tmp/firstboot.exec
./bin/bash
as root./tmp/firstboot.log
./tmp/firstboot.exec
./bin/sh
as root./tmp/firstboot.log
.C:\image\firstboot.cmd
.cmd.exe
as Administrator.C:\image\firstboot.log
A PXE script automates installation of custom operating systems. A PXE script will be executed by iPXE every time your server starts, but only if there is no operating system installed to the server's disk.
Startup scripts may query the Vultr Metadata API to discover information about the instance. This script logs the metadata for the deployed instance to /tmp/metadata.json
.
#/bin/sh
curl -o /tmp/metadata.json http://169.254.169.254/v1.json
Your script can manipulate the JSON metadata with tools such as jq, Python, sed, awk, or grep. For example, you could use the metadata to discover your IP address and generate configuration files automatically on first boot.
This example installs a public key for SSH authorization. Replace "ssh-rsa AA... youremail@example.com" with your SSH public key info.
#!/bin/sh
mkdir -p /root/.ssh
chmod 600 /root/.ssh
echo ssh-rsa AA... youremail@example.com > /root/.ssh/authorized_keys
chmod 700 /root/.ssh/authorized_keys
This is an example that boots CoreOS. You need to add your SSH key before this will work.
#!ipxe
set base-url http://stable.release.core-os.net/amd64-usr/current
kernel ${base-url}/coreos_production_pxe.vmlinuz sshkey="ssh-rsa AAAA..." cloud-config-url=http://169.254.169.254/2014-09-12/coreos-init
initrd ${base-url}/coreos_production_pxe_image.cpio.gz
boot
The Vultr API offers several endpoints to manage startup scripts.
You could earn up to $300 by adding new articles