I'm trying to setup a cloud-config file to invoke a script that will run
apt-get to update packages and install a few additional packages. Because
the kernel can be updated by the 'apt-get upgrade', I want to reboot at the
end to activate the new kernel.

Given that the cloud-config will be executed during the boot process itself
(during the first boot), what is the best practice for scheduling a reboot?
Should I just do it immediately (i.e., leaving some of the boot scripts
perhaps unexecuted in the first boot) or should I schedule it for 10
seconds later (i.e., guessing that the remaining boot scripts will have
completed by then) or is there some better way to handle this scenario.

Here is what I think (not yet tried) my cloud-config file would look like:

#cloud-config
runcmd:
 - [ sh, "/mnt/data/setup/init.sh'" ]

Here is my init.sh script (tested via sudo from 'ubuntu' user command line
and works there):

#! /bin/sh
#

# Get security and distribution updates
# (Note: sec.sources.list is a copy of sources.list with only security
sources specified)
#
apt-get update
apt-get upgrade -o Dir::Etc::sourcelist=/etc/apt/sec.sources.list

# Install llvm and clang
#
apt-get install llvm-3.0
apt-get install llvm-3.0-doc
apt-get install llvm-3.0-dev
apt-get install clang

# Update the CNAME for dev.mydomain.com to point to this
# instance
#
INSTANCE_ID_=`curl -s -g
http://169.254.169.254/latest/meta-data/instance-id`
# echo instance id is $INSTANCE_ID_
PUBLIC_HOSTNAME_=`curl -s -g
http://169.254.169.254/latest/meta-data/public-hostname`
# echo public hostname is $PUBLIC_HOSTNAME_
python setr53.py $INSTANCE_ID_ $PUBLIC_HOSTNAME_

# restart the system to pick up kernel changes
# (yep, there might not have been any, but reboot anyway)
#
shutdown -r now


--
Dave Hein
-- 
Ubuntu-cloud mailing list
Ubuntu-cloud@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-cloud

Reply via email to