[Lunar-commits] r25933 - moonbase/trunk/utils/lunar-init

Auke Kok sofar at lunar-linux.org
Sat Sep 22 07:27:35 CEST 2007


Author: sofar
Date: 2007-09-22 07:27:34 +0200 (Sat, 22 Sep 2007)
New Revision: 25933

Modified:
   moonbase/trunk/utils/lunar-init/DETAILS
   moonbase/trunk/utils/lunar-init/network
Log:
Haven't we learned from our mistakes? DO NOT HARDCODE PATHS to mission-critical components. Just use `which` and make it all work out if stuff changes. Maybe it will!


From:  sofar at foo-projects.org


Modified: moonbase/trunk/utils/lunar-init/DETAILS
===================================================================
--- moonbase/trunk/utils/lunar-init/DETAILS	2007-09-22 05:27:27 UTC (rev 25932)
+++ moonbase/trunk/utils/lunar-init/DETAILS	2007-09-22 05:27:34 UTC (rev 25933)
@@ -2,7 +2,7 @@
          VERSION=0.1
         WEB_SITE=http://lunar-linux.org
          ENTERED=20070404
-         UPDATED=20070407
+         UPDATED=20070921
            SHORT="the Lunar init scripts vital to any system"
          PROFILE=yes
 

Modified: moonbase/trunk/utils/lunar-init/network
===================================================================
--- moonbase/trunk/utils/lunar-init/network	2007-09-22 05:27:27 UTC (rev 25932)
+++ moonbase/trunk/utils/lunar-init/network	2007-09-22 05:27:34 UTC (rev 25933)
@@ -9,11 +9,11 @@
 
 shopt -s extglob
 CONFIGS="/etc/config.d/network"
-IFPLUGD="/usr/sbin/ifplugd"
-WPA_SUPPLICANT="/usr/sbin/wpa_supplicant"
-IFCONFIG="/sbin/ifconfig"
-IWCONFIG="/usr/sbin/iwconfig"
-ROUTE="/sbin/route"
+IFPLUGD=$(which ifplugd 2> /dev/null)
+WPA_SUPPLICANT=$(which wpa_supplicant 2> /dev/null)
+IFCONFIG=$(which ifconfig 2> /dev/null)
+IWCONFIG=$(which iwconfig 2> /dev/null)
+ROUTE=$(which route 2> /dev/null)
 
 chkresult()
 {
@@ -34,18 +34,18 @@
 	case $DHCP_CLIENT in
 			[dD][hH][cC][pP][cC][dD])
 			PIDFILE=/var/run/dhcpcd-$1.pid
-			RUNFILE=/sbin/dhcpcd
+			RUNFILE=$(which dhcpcd 2> /dev/null)
 		;;
 			
 			[dD][hH][cC][lL][iI][eE][nN][tT])
 			PIDFILE=/var/run/dhclient-$1.pid
-			RUNFILE=/sbin/dhclient
+			RUNFILE=$(which dhclient 2> /dev/null)
 			DHCP_OPTIONS="$DHCP_OPTIONS -pf $PIDFILE -lf /var/state/dhcp/dhclient-$1.leases"
 		;;
 			
 			[uU][dD][hH][cC][pP][cC])
 			PIDFILE=/var/run/udhcpc-$1.pid
-			RUNFILE=/sbin/udhcpc
+			RUNFILE=$(which udhcpc 2> /dev/null)
 			DHCP_OPTIONS="$DHCP_OPTIONS -p $PIDFILE -i"
 		;;
 	esac
@@ -322,7 +322,7 @@
 {
 	if [ -z "$2" ]; then
 		echo "Stopping network:"
-		for device in `/sbin/ifconfig | cut -d" " -f1 | uniq | grep -E [a-z0-9]+ | grep -v lo | sort -r`; do
+		for device in `$IFCONFIG | cut -d" " -f1 | uniq | grep -E [a-z0-9]+ | grep -v lo | sort -r`; do
 			echo -n " * Stopping $device: "
 			device_stop $device auto
 			chkresult



More information about the Lunar-commits mailing list