Hello,

Here are the patches for adding pre- alt- and post- functions for unattended 
linuxboot.

Fredag 02 november 2007 16:21, skrev Nils Olav Fossum:
> predosemu_cmd - System command to run before dosemu
> alt_dosemu_cmd - Alternate System command to run in place of dosemu
> postdosemu_cmd - System command to run after dosemu

So, to get a system command to run after dosemu i put
(under the [_meta] header in unattend.txt):

postdosemu_cmd = "/z/site/sh/_testpostdosemu.sh"

> Right now I plan to use postdosemu_cmd for fixing up mbr for Thinkpads and
> other troublesome machines with 240 heads.

Yep, thats still the main reason for these changes.

So, I hope to get this into CVS. :-)

Comments?

-- 
Nils Olav
--- unattended/linuxboot/misc/master-cvs	2007-11-21 00:12:36.000000000 +0100
+++ unattended/linuxboot/misc/master	2007-11-21 02:49:16.000000000 +0100
@@ -368,14 +368,6 @@
 
 echo "*** By Jove, I think we've got it!"
 
-# FIXME: Bad hack to work around dosemu bug running over network
-rm /usr/bin/dosemu.bin
-cp /z/linuxaux/usr/bin/dosemu.bin /usr/bin/dosemu.bin
-rm -f /var/lib /var/lib/dosemu /var/lib/dosemu/drives \
-    /var/lib/dosemu/drives/dosboot.img >/dev/null 2>&1
-mkdir -p /var/lib/dosemu/drives
-cp /z/linuxaux/var/lib/dosemu/drives/dosboot.img /var/lib/dosemu/drives/.
-
 # install.pl relies on these environment variables
 # (see also LEGACY_BIOS_HEAD and LEGACY_BIOS_SECT above)
 export Z_PATH Z_USER Z_PASS
@@ -396,11 +388,47 @@
     die "No active partition found!"
 fi
 
-cp /etc/dosemu/dosemu.conf /tmp
-echo \$_hdimage = \"/dev/dsk$active_part\" >> /tmp/dosemu.conf
+#load functions so we can parse /c/netinst/unattend.txt:
+[ -f /etc/functions.sh ] || die "/z/linuxaux/etc/functions.sh not found" 
+. /etc/functions.sh
+
+predosemu_cmd=`parse_ini_file /c/netinst/unattend.txt _meta predosemu_cmd`
+alt_dosemu_cmd=`parse_ini_file /c/netinst/unattend.txt _meta alt_dosemu_cmd`
+postdosemu_cmd=`parse_ini_file /c/netinst/unattend.txt _meta postdosemu_cmd`
+
+if [ -n "$predosemu_cmd" ]
+then
+    echo -e "* Running predosemu_cmd: $predosemu_cmd\n"
+    $predosemu_cmd || die "* $predosemu_cmd exited non-zero"
+fi
 
-# DOSEMU always exits non-zero.  FIXME.
-dosemu.bin -f /tmp/dosemu.conf
+if [ -z "$alt_dosemu_cmd" ]
+then  
+    #Run the orginal dosemu:
+
+    # FIXME: Bad hack to work around dosemu bug running over network
+    rm /usr/bin/dosemu.bin
+    cp /z/linuxaux/usr/bin/dosemu.bin /usr/bin/dosemu.bin
+    rm -f /var/lib /var/lib/dosemu /var/lib/dosemu/drives \
+       /var/lib/dosemu/drives/dosboot.img >/dev/null 2>&1
+    mkdir -p /var/lib/dosemu/drives
+    cp /z/linuxaux/var/lib/dosemu/drives/dosboot.img /var/lib/dosemu/drives/.
+
+    cp /etc/dosemu/dosemu.conf /tmp
+    echo \$_hdimage = \"/dev/dsk$active_part\" >> /tmp/dosemu.conf
+
+    # DOSEMU always exits non-zero.  FIXME.
+    dosemu.bin -f /tmp/dosemu.conf
+else
+    echo -e "* Running alt_dosemu_cmd: $alt_dosemu_cmd\n"
+    $alt_dosemu_cmd || die "* $alt_dosemu_cmd exited non-zero"
+fi
+
+if [ -n "$postdosemu_cmd" ]
+then
+    echo -e "* Running postdosemu_cmd: $postdosemu_cmd\n"
+    $postdosemu_cmd || die "* $postdosemu_cmd exited non-zero"
+fi
 
 sync
 reboot
--- /dev/null	2007-11-20 01:54:46.780047835 +0100
+++ unattended/linuxboot/misc/functions.sh	2007-11-19 20:08:45.000000000 +0100
@@ -0,0 +1,24 @@
+
+#this funtion is stolen from one of Mario Gzuk's unattended-gui scripts 
+function parse_ini_file ()
+	{
+	# options are
+	# 1 the ini file
+	# 2 the sektion name
+	# 3 the key name
+	if [ -r $1 ]
+	then
+		cat $1 |  sed 's/;/#/' | sed -e 's/[[:space:]]*\=[[:space:]]*/=/g'  -e 's/;.*$//'  -e 's/[[:space:]]*$//'  -e 's/^[[:space:]]*//'  -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" | sed -n -e "/^\[$2\]/,/^\s*\[/{/^[^;].*\=.*/p;}" | sed 's/\\/\\\\/g' | while read LINE
+		do
+			MATCH=`echo $LINE | awk -F\= '{print $1}'`
+			M1=`echo $MATCH | tr '[A-Z]' '[a-z]'`
+			M2=`echo $3 | tr '[A-Z]' '[a-z]'`
+			if [ "$M1" == "$M2" ]
+			then
+				echo $LINE | awk -F\= '{print $2}' | sed 's/^"//' | sed 's/"$//'
+			fi
+		done
+	fi
+	}
+
+
--- unattended/linuxboot/Makefile-cvs	2007-11-21 00:48:47.000000000 +0100
+++ unattended/linuxboot/Makefile	2007-11-21 03:04:33.000000000 +0100
@@ -788,6 +788,8 @@
 
 $(call copy_file,misc/freedos-mbr.bin,stage1/usr/lib/freedos-mbr.bin)
 
+$(call copy_file,misc/functions.sh,stage1/etc/functions.sh)
+
 # Some apps (namely dosemu) need getpwnam() etc. to work
 $(call copy_file,misc/passwd,stage1/etc/passwd)
 
@@ -797,7 +799,8 @@
 		stage1/etc/master stage1/etc/modprobe.conf		\
 		stage1/etc/module-order.txt				\
 		stage1/etc/udhcpc-script stage1/etc/nsswitch.conf	\
-		stage1/etc/passwd stage1/usr/lib/freedos-mbr.bin
+		stage1/etc/passwd stage1/usr/lib/freedos-mbr.bin	\
+		stage1/etc/functions.sh
 
 # /etc/version
 stage1/etc/version: FORCE
--- unattended/install/dosbin/install.pl-cvs	2007-11-21 11:37:52.000000000 +0100
+++ unattended/install/dosbin/install.pl	2007-11-21 12:02:46.000000000 +0100
@@ -994,6 +994,21 @@
                 : undef);
     };
 
+$u->comments ('_meta', 'predosemu_cmd') =
+    ['System command to run before dosemu? (linuxboot only)'];
+#$u->{'_meta'}->{'predosemu_cmd'} = '';
+
+
+$u->comments ('_meta', 'alt_dosemu_cmd') =
+    ['Alternate System command to run in place of dosemu? (linuxboot only)'];
+#$u->{'_meta'}->{'alt_dosemu_cmd'} = '';
+
+
+$u->comments ('_meta', 'postdosemu_cmd') =
+    ['System command to run after dosemu? (linuxboot only)'];
+#$u->{'_meta'}->{'postdosemu_cmd'} = '';
+
+
 $u->{'_meta'}->{'ipaddr'} =
     sub {
         my $ret;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
unattended-devel mailing list
unattended-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unattended-devel

Reply via email to