RedHat initialization script and bash2

Jamie Briggs jamie.briggs at computalog.com
Fri Jun 16 22:48:16 CEST 2000


On Fri, Jun 16, 2000 at 07:45:14AM +0200, Guus Sliepen wrote:
> On Thu, 15 Jun 2000, Jamie Briggs wrote:
> 
> > Installing the new tinc on a system (Mandrake 7.0) that uses bash2 as it shell
> > turned up a problem with the redhat initialization script.
> 
> > Attached is a patch to make it functional for both bash and bash2.
> 
> Thank you! The patch has been applied to the CVS version.
> 
> Met vriendelijke groet,
> Guus Sliepen.
> 

I slipped up, though, with my original post.  Further testing today turned
up a problem with the MAC address setting.  The cause turned out to
be another { } grouping that needed a trailing semicolon.

I've attached a revised patch.

- Jamie
-------------- next part --------------
diff -uNr tinc-1.0pre2.org/redhat/tinc tinc-1.0pre2/redhat/tinc
--- tinc-1.0pre2.org/redhat/tinc	Fri May 26 05:22:49 2000
+++ tinc-1.0pre2/redhat/tinc	Fri Jun 16 14:32:39 2000
@@ -117,7 +117,7 @@
 
 vpn_load () {
     CFG="$TCONF/$1/tinc.conf"
-    [ -f $CFG ] || { MSG="$CFG does not exist!"; return 1 }
+    [ -f $CFG ] || { MSG="$CFG does not exist!"; return 1; }
     
     # load TINCD config
     DEV="$(grep -i -e '^[[:space:]]*TapDevice' $CFG | sed 's/[[:space:]]//g; s/^.*=//g')"
@@ -126,24 +126,24 @@
     
     # TapDevice syntax validation
     [ -z "$DEV" ] && \
-	{ MSG="TapDevice required!"; return 1 }
+	{ MSG="TapDevice required!"; return 1; }
     [ $(echo $DEV | wc -l) -gt 1 ] && \
-	{ MSG="multiple TapDevice entries not allowed!"; return 1 }
+	{ MSG="multiple TapDevice entries not allowed!"; return 1; }
     echo $DEV | grep -q -x -E '/dev/tap[[:digit:]]+' ||
-	{ MSG="TapDevice should be in form /dev/tapX!"; return 1 }
+	{ MSG="TapDevice should be in form /dev/tapX!"; return 1; }
 
     # MyOwnVPNIP/MyVirtualIP syntax validation	
     [ -z "$VPN" ] && \
-	{ MSG="MyOwnVPNIP/MyVirtualIP required!"; return 1 }
+	{ MSG="MyOwnVPNIP/MyVirtualIP required!"; return 1; }
     [ $(echo $VPN | wc -l) -gt 1 ] && \
-	{ MSG="multiple MyOwnVPNIP/MyVirtualIP entries not allowed!"; return 1 }
+	{ MSG="multiple MyOwnVPNIP/MyVirtualIP entries not allowed!"; return 1; }
     echo $VPN | grep -q -x -E \
 	'([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}/[[:digit:]]{1,2}' || \
-	{ MSG="badly formed MyOwnVPNIP/MyVirtualIP address $VPN!"; return 1 }
+	{ MSG="badly formed MyOwnVPNIP/MyVirtualIP address $VPN!"; return 1; }
 
     # VPNMask syntax validation	
     [ $(echo $IFM | wc -l) -gt 1 ] && \
-	{ MSG="multiple VPNMask entries not allowed!"; return 1 }
+	{ MSG="multiple VPNMask entries not allowed!"; return 1; }
 	
 	                                                                                    
     # device & IP address extraction
@@ -180,7 +180,7 @@
     NET=$(ipcalc --network $ADR $MSK | cut -d"=" -f2)
 
     # MAC address
-    MAC=$(printf "fe:fd:%0.2x:%0.2x:%0.2x:%0.2x" $(echo $ADR | { IFS=. ; read a b c d; echo $a $b $c $d }))
+    MAC=$(printf "fe:fd:%0.2x:%0.2x:%0.2x:%0.2x" $(echo $ADR | { IFS=. ; read a b c d; echo $a $b $c $d; }))
     
     # debugging 
     # echo >&2
@@ -208,21 +208,21 @@
     
     # load device module
     ERR="$(insmod ethertap -o "ethertap$NUM" unit="$NUM" 2>&1 1> /dev/null)" ||
-        { MSG="could not insmod ethertap as unit $NUM!"; return 2 }
+        { MSG="could not insmod ethertap as unit $NUM!"; return 2; }
     
     # configure the interface
     ERR="$(ip link set $TAP address $MAC 2>&1)" ||
-    	{ MSG="could not set address for device $TAP!"; return 3 }
+    	{ MSG="could not set address for device $TAP!"; return 3; }
 	
     ERR="$(ip link set $TAP up 2>&1)" ||
-    	{ MSG="could not bring up device $TAP!"; return 3 }
+    	{ MSG="could not bring up device $TAP!"; return 3; }
 	
     ERR="$(ip addr add $VPN brd $BRD dev $TAP 2>&1)" ||
-    	{ MSG="could not set IP address for device $TAP!"; return 3 }
+    	{ MSG="could not set IP address for device $TAP!"; return 3; }
     
     # start tincd
     $TINCD --net="$1" $DEBUG || \
-	{ MSG="could not start daemon for network $1"; return 3 }
+	{ MSG="could not start daemon for network $1"; return 3; }
 
     # setup custom static routes
     /etc/sysconfig/network-scripts/ifup-routes $TAP


More information about the Tinc mailing list