From 5bfc504fda59f41d4347c09ca43ffec861b8cdad Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Thu, 7 Aug 2014 18:01:50 +0100 Subject: [PATCH] Introduce remainder of Ubuntu support Note Ubuntu does not currently use or properly support systemd, so we cannot obtain a nice systemd-analyze output. So for now we'll just emit the "uptime" number, which is entirely incorrect but cannot be helped, and is just a formatting placeholder until Ubuntu 14.10 stable supports systemd. Signed-off-by: Ikey Doherty --- Makefile.am | 8 +++-- data/vm-report.init | 61 +++++++++++++++++++++++++++++++++++++ scripts/gen-ubuntu-rawfs.sh | 1 + scripts/vm-report.sh | 6 +++- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 data/vm-report.init diff --git a/Makefile.am b/Makefile.am index fcae82c..b999bf2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,12 +9,14 @@ bin_PROGRAMS = \ vm-timing-report bin_SCRIPTS = \ - scripts/spin-from-raw.sh + scripts/spin-from-raw.sh \ + scripts/gen-ubuntu-rawfs.sh supportdir = $(datadir)/vm-timing-report support_DATA = \ scripts/vm-report.sh \ - data/vm-report.service + data/vm-report.service \ + data/vm-report.init vm_timing_report_SOURCES = \ src/vm-timing-report.c @@ -32,5 +34,7 @@ EXTRA_DIST = \ LICENSE \ scripts/vm-report.sh \ scripts/spin-from-raw.sh \ + scripts/gen-ubuntu-rawfs.sh + data/vm-report.init data/vm-report.service diff --git a/data/vm-report.init b/data/vm-report.init new file mode 100644 index 0000000..6967552 --- /dev/null +++ b/data/vm-report.init @@ -0,0 +1,61 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: vm-timing-report +# Required-Start: $syslog $remote_fs $network +# Required-Stop: $syslog $remote_fs $network +# Default-Start: 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start the vm-timing-report service +# Description: VM Timing Report script +### END INIT INFO + + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/bin/vm-report +NAME=vm-timing-report +DESC="VM Timing Report" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +test -x $DAEMON || exit 0 + +set -e + +. /lib/lsb/init-functions + +case "$1" in + start) + log_daemon_msg "Starting $DESC" $NAME + if ! start-stop-daemon --start --quiet \ + --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS + then + log_end_msg 1 + else + log_end_msg 0 + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" $NAME + if start-stop-daemon --stop --retry 30 --quiet \ + --pidfile $PIDFILE --exec $DAEMON + then + rm -f $PIDFILE + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + restart) + $0 stop + $0 start + ;; + status) + status_of_proc -p "$PIDFILE" "$DAEMON" vm-timing-report && exit 0 || exit $? + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/scripts/gen-ubuntu-rawfs.sh b/scripts/gen-ubuntu-rawfs.sh index 094b5fc..6720348 100755 --- a/scripts/gen-ubuntu-rawfs.sh +++ b/scripts/gen-ubuntu-rawfs.sh @@ -51,6 +51,7 @@ install -m 0700 /usr/share/vm-timing-report/vm-report.init $MOUNTPOINT/etc/init. install -m 0755 /usr/share/vm-timing-report/vm-report.sh $MOUNTPOINT/usr/bin/vm-report chroot $MOUNTPOINT update-rc.d vm-report defaults +chroot $MOUNTPOINT update-rc.d vm-report enable sleep 1 sync diff --git a/scripts/vm-report.sh b/scripts/vm-report.sh index cb4ab36..147f53d 100644 --- a/scripts/vm-report.sh +++ b/scripts/vm-report.sh @@ -21,7 +21,11 @@ done while : do - ANALYZE="`systemd-analyze`" + if [[ -e /usr/lib/upstart || ! -e /dev/virtio-ports/serial0 ]]; then + ANALYZE="`uptime`" + else + ANALYZE="`systemd-analyze`" + fi if [[ $? -ne 0 ]]; then # Must wait for systemd-analyze to report a boot time, # otherwise this is not considered "booted"