From bc6ccf22adfcfb10f180b8f85618e38a1672acb7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Fri, 17 Sep 2010 15:15:33 +0200 Subject: add function to manipulate upstart scripts // openslx-commit test :) --- .../distro-specs/ubuntu/functions-default | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/initramfs/distro-specs/ubuntu/functions-default') diff --git a/src/initramfs/distro-specs/ubuntu/functions-default b/src/initramfs/distro-specs/ubuntu/functions-default index 1fdbf6bb..51027c90 100644 --- a/src/initramfs/distro-specs/ubuntu/functions-default +++ b/src/initramfs/distro-specs/ubuntu/functions-default @@ -80,6 +80,34 @@ initial_boot () { : } +upstart_set_starton () { + local script="$1" + local starton="$2" + local file_not_found="f" + + if [ -e /mnt/etc/init.inactive/${script}.conf ]; then + local script_path=/mnt/etc/init.inactive/${script}.conf + elif [ -e /mnt/etc/init/${script}.conf ]; then + local script_path=/mnt/etc/init/${script}.conf + else + local file_not_found="t" + fi + + if [ "$file_not_found" = "f" ]; then + # replace multi-line dependencies with ##starton## + sed -n '1h;1!H;${;g;s/start on[\t ]*([^)]*)/start on ##starton##/g;p;}' \ + -i $script_path + # replace single-line dependencies with ##starton## + sed -e 's/start on.*$/start on ##starton##/' \ + -i $script_path + # replace placeholder with our new value + sed -e "s,##starton##,$starton," + -i $script_path + else + error "Script: ${script} does not exist. Skipping modification.." nonfatal} + fi +} + # runlevel linker - mostly deprecated in the old form because of new upstart # mechanism (with backward compatibility) rllinker () { -- cgit v1.2.3-55-g7522