From 67986167a8377fdaf3f62cb89bea44f2ae53b6d5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Wed, 15 Oct 2008 02:16:55 +0000 Subject: * init-wrapper now supports second parameter (DEBUGLEVEL) to trigger "set -x" * init-wrapper is building diffs from "env" they are stored in /tmp/env and will be included in the next use of init-wrapper important: you have to set the variables with export git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2309 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initramfs/stage3-stuff/bin/init-wrapper | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'initramfs') diff --git a/initramfs/stage3-stuff/bin/init-wrapper b/initramfs/stage3-stuff/bin/init-wrapper index 3efd1cf4..d0b58239 100755 --- a/initramfs/stage3-stuff/bin/init-wrapper +++ b/initramfs/stage3-stuff/bin/init-wrapper @@ -1,4 +1,4 @@ -#!/bin/ash +#!/bin/sh # Copyright (c) 2006..2008 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. @@ -12,6 +12,12 @@ # wrapperscript for plugin init files ############################################################################# +# get parameters +init_file="$1" +DEBUGLEVEL="$2" + +[ -z $DEBUGLEVEL ] && DEBUGLEVEL=0 + # how do the localization here? There is not yet a country-Variable . /etc/messages . /etc/functions @@ -24,5 +30,29 @@ # a certain InitRamFS generated by slxconfig-demuxer) [ -f /etc/initramfs-setup ] && . /etc/initramfs-setup 2>/dev/null -[ -f $1 ] && . $1 +# initial +[ -d /tmp/env ] || mkdir -p /tmp/env + +# load temporary environments +for tmpenv in /tmp/env/* +do + [ -f "$tmpenv" ] && . $tmpenv +done + +# get environment and prepare as sed command +pre_env=$(env | sed -e 's/^\([^=]*\).*/\1/' | tr '\n' ';') +pre_env=$(echo $pre_env| sed -e 's/;/\.\*\/\/;s\/\^/g') +pre_env="s/^$pre_env//;" + +[ "${DEBUGLEVEL}" -gt 10 -a "${DEBUGLEVEL}" -le 20 ] && set -x +[ -f $init_file ] && . $init_file +[ "${DEBUGLEVEL}" -gt 10 -a "${DEBUGLEVEL}" -le 20 ] && set +x + +outfile=$(basename $init_file) +outfile="${outfile}.env" +# remove already known environment variables from postenv +env |sed -e $pre_env | sort -u | \ + sed -e '1s/.*/#generated by init-wrapper/' | \ + sed -e 's/^\([^=]*\)=\(.*\)/\1="\2"/' \ + > /tmp/env/$outfile -- cgit v1.2.3-55-g7522