summaryrefslogtreecommitdiffstats
path: root/initramfs/stage3-stuff/bin/init-wrapper
diff options
context:
space:
mode:
authorSebastian Schmelzer2008-10-15 04:16:55 +0200
committerSebastian Schmelzer2008-10-15 04:16:55 +0200
commit67986167a8377fdaf3f62cb89bea44f2ae53b6d5 (patch)
tree82e3968086fe957504bd64a3820d2103e3c9c403 /initramfs/stage3-stuff/bin/init-wrapper
parentHint for changed behaviour for init-hooks in other scripts (see #259). (diff)
downloadcore-67986167a8377fdaf3f62cb89bea44f2ae53b6d5.tar.gz
core-67986167a8377fdaf3f62cb89bea44f2ae53b6d5.tar.xz
core-67986167a8377fdaf3f62cb89bea44f2ae53b6d5.zip
* 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
Diffstat (limited to 'initramfs/stage3-stuff/bin/init-wrapper')
-rwxr-xr-xinitramfs/stage3-stuff/bin/init-wrapper34
1 files changed, 32 insertions, 2 deletions
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