[09:02] <jmux> Hi. Im on Ubuntu 12.04. I'm using FAI for software updates and want to run FAI on boot and trigger a reboot after the system was updated. Currently my job starts on starting kdm to run before X. Calling reboot just deadlocks the system in a state of starting an stopping jobs. How can I reboot my system from within an upstart job?
[09:06] <jmux> joint #kubuntu-devel
[09:14] <xnox> jmux: can you paste your job?
[09:34] <jmux> xnox: http://paste.ubuntu.com/6005780/ and http://paste.ubuntu.com/6005791/
[09:37] <jmux> xnox: the first script is the upstart job, the second the actual script (/etc/init.d/goto-configure-online). The FAI call is at the end of the second script (fai -N softupdate).
[09:38] <xnox> jmux: that looks weird. usually scripts under /etc/init.d/* are started as normal sysv-init scripts by upstart when it is ready. Your start on condition for network is not deterministic. 
[09:38] <xnox> jmux: maybe "start on (local-filesystems and net-device-up IFACE!=lo)" is better as you will have network at that point.
[09:39] <xnox> jmux: you only need to reboot if "/var/run/reboot-required" is present after upgrades.
[09:41] <xnox> jmux: instead of FAI, i'd use unattended-upgrades and cron those instead.
[09:41] <xnox> jmux: with respect to hang debug the script & environment it's running under. is it expecting input or some other environment vars?
[09:42] <xnox> jmux: instead of starting your init.d script from the upstart job: add proper LSB headers, remove upstart job, and let the init.d script be started by sysv-init.
[09:42] <jmux> xnox: probably - this is an old job originating from 10.04 :-)
[09:42] <xnox> as it should be.
[09:44] <xnox> jmux: it looks very odd. in 12.04 there are many improvements for sssd/slapd et.al.  i'd start splitting that mega script into smaller chunks / separate jobs. whilst carefully considering if all the chunks are still needed.
[09:45] <jmux> xnox: I'm fixed on FAI and the update has to run on boot. The update is triggered via a variable in LDAP.
[09:45] <xnox> jmux: i see.
[09:51] <jmux> Just some background - this is running on a client, we have our own APT repositories and we just update during startup, especially if you do a dist-upgrade from a previous release.. So back to my original problem - is there a way to reboot my machine from within an upstart job without deadlocking upstart? 
[10:01] <xnox> jmux: one can. e.g. cloud-init has ability to apply updates and reboot the machine. but it does it before starting $most of the sysv-init scripts. One would reboot with "reboot", not "poweroff".
[10:07] <jmux> xnox: ok - I'll check cloud-init and adopt my upstart jobs to the new "have network" dependency.
[10:09] <jmux> I don't think there is a big difference between reboot or poweroff for upstart.
[10:10] <xnox> jmux: poweroff cuts the power to the machine. and it doesn't come back up. with reboot it does.
[10:11] <xnox> jmux: this may have been different in the past, but with newer kernels that's what the behaviour is.
[10:11] <xnox> (and should be)
[10:13] <jmux> xnox: yeah - I know :-) But from the upstart POV it just has to stop all jobs and prevent new jobs from starting, which it currently fails to handle, at least on 12.04.
[10:15] <xnox> jmux: oh I see. so upstart stops all the jobs that it manages, and then changes the runlevel to stop all the init.d scripts. At that point sendsigs/syv-init completes the shutdown sequences.
[10:15] <xnox> jmux: those init.d scripts can hang the shutdown, and unfortunately it's outside of upstart's control at that point (upstart is not running any more)
[10:16] <xnox> increasing the upstart logging (e.g. boot with kernelarg --debug) should show if it's upstart job that hang.
[10:20] <jmux> xnox: I'll check that and report back, but it may take a few minutes.