############################### Xenial ######################################### gcloud compute instances create ubuntu-1604-xenial-v20170307 --image-project ubuntu-os-cloud --image "ubuntu-1604-xenial-v20170307" --metadata shutdown-script="#! /bin/bash touch /home/ubuntu/shutdown.txt",startup-script="#! /bin/bash touch /home/ubuntu/startup.txt" # Run the following on the running instance # clean up instance ready for testing rm -f ~/startup.txt #Enable proposed echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main multiverse universe" | sudo tee --append /etc/apt/sources.list sudo apt-get update sudo apt-get install --only-upgrade gce-compute-image-packages # Note that the first upgrade will always result in shutdown # scripts being run as the initial gce-compute-image-packages postrm script are still in use. # verify that the bug still exists if [ -f ~/shutdown.txt ]; then echo "Shutdown File found! Bug still present" rm -f ~/shutdown.txt fi # Add PPA with a higher version number of the same package so we can test upgrade with the same package sudo add-apt-repository -y ppa:philroche/lp1668327-startupscript-package-update-xenial sudo apt-get update sudo apt-get install --only-upgrade gce-compute-image-packages if [ ! -f ~/shutdown.txt ]; then echo "Shutdown File not found! Bug fixed" fi # start up and shutdown scripts are no longer started by # default on upgrade or install so we should start these manually now. # They will continue to restart on instance boot though. sudo service google-shutdown-scripts status sudo service google-shutdown-scripts start # clean up instance ready for testing rm -f ~/shutdown.txt ~/startup.txt # restart to test startup and shutdown scripts still work sudo reboot if [ -f ~/startup.txt ]; then echo "Startup File found! Startup scripts work" rm -f ~/startup.txt fi if [ -f ~/shutdown.txt ]; then echo "Shutdown File found! Shutdown scripts work" rm -f ~/shutdown.txt fi # If you wish to reset completely run the following rm -f ~/shutdown.txt ~/startup.txt sudo apt-get install ppa-purge sudo ppa-purge -y ppa:philroche/lp1668327-startupscript-package-update-xenial