I have a VM that needs to boot up, perform a specific task, and then shut itself down.
It also needs to be possible to abort the special startup sequence to get the "regular" bootup behaviour, i.e. either before the application run, or before the shutdown.
I've tried to accomplish this using the following in
#!/bin/bash trap "echo;echo Resuming regular system startup...;exit" SIGINT echo "Press Ctrl+C within 10 seconds to skip application run..." sleep 10 su ubuntu -c /home/ubuntu/application.py echo "Press Ctrl+C within 30 seconds to abort shutdown..." sleep 30 shutdown -h now
This runs fine and works as expected when I just execute it directly as /etc/rc.local as root, when logged in, but it would appear it doesn't work when it's actually run as a part of system startup. It runs fine, but it doesn't respond to Ctrl+C to actually be abortable.
SSH:ing in during the execution of this script and issuing a
killall -INT rc.local also does not seem to stop the execution of the script,
killall -9 rc.local does stop it though, and drops the console into
It appears this system uses upstart for booting, as determined below:
root@fundie:~# ps 1 PID TTY STAT TIME COMMAND 1 ? Ss 0:01 /sbin/init root@fundie:~# /sbin/init --version init (upstart 1.12.1) Copyright (C) 2006-2014 Canonical Ltd., 2011 Scott James Remnant This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
What am I missing?