]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add entry, exit and resolv.conf hooks.
authorTed Lemon <source@isc.org>
Mon, 29 Mar 1999 22:35:19 +0000 (22:35 +0000)
committerTed Lemon <source@isc.org>
Mon, 29 Mar 1999 22:35:19 +0000 (22:35 +0000)
client/scripts/bsdos
client/scripts/freebsd
client/scripts/netbsd
client/scripts/solaris

index 77fdc5c9f26ee54fb723697e249566dd0bc0f0c8..d9e44b40d08839a87dffde13ecc2006f5f423a05 100755 (executable)
@@ -1,5 +1,33 @@
 #!/bin/sh
 
+make_resolv_conf() {
+  echo search $new_domain_name >/etc/resolv.conf
+  for nameserver in $new_domain_name_servers; do
+    echo nameserver $nameserver >>/etc/resolv.conf
+  done
+}
+
+# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
+exit_with_hooks() {
+  exit_status=$1
+  if [ -x /etc/dhclient-exit-hooks ]; then
+    . /etc/dhclient-exit-hooks
+  fi
+# probably should do something with exit status of the local script
+  exit $exit_status
+}
+
+# Invoke the local dhcp client enter hooks, if they exist.
+if [ -x /etc/dhclient-enter-hooks ]; then
+  exit_status=0
+  . /etc/dhclient-enter-hooks
+  # allow the local script to abort processing of this state
+  # local script must set exit_status variable to nonzero.
+  if [ $exit_status -ne 0 ]; then
+    exit $exit_status
+  fi
+fi
+
 if [ x$new_network_number != x ]; then
    echo New Network Number: $new_network_number
 fi
@@ -25,7 +53,7 @@ if [ x$reason = xMEDIUM ]; then
   ifconfig $interface $medium
   ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
   sleep 1
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xPREINIT ]; then
@@ -35,11 +63,11 @@ if [ x$reason = xPREINIT ]; then
   fi
   ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
                broadcast 255.255.255.255 up
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
-  exit 0;
+  exit_with_hooks 0;
 fi
   
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
@@ -89,7 +117,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   for nameserver in $new_domain_name_servers; do
     echo nameserver $nameserver >>/etc/resolv.conf
   done
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
@@ -117,7 +145,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
     route add $alias_ip_address 127.0.0.1
   fi
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xTIMEOUT ]; then
@@ -153,7 +181,7 @@ if [ x$reason = xTIMEOUT ]; then
        rm -f /etc/resolv.conf
       fi
       mv /etc/resolv.conf.std /etc/resolv.conf
-      exit 0
+      exit_with_hooks 0
     fi
   fi
   ifconfig $interface inet -alias $new_ip_address $medium
@@ -169,7 +197,7 @@ if [ x$reason = xTIMEOUT ]; then
   fi
   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                        |sh >/dev/null 2>&1
-  exit 1
+  exit_with_hooks 1
 fi
 
-exit 0
+exit_with_hooks 0
index 77fdc5c9f26ee54fb723697e249566dd0bc0f0c8..d9e44b40d08839a87dffde13ecc2006f5f423a05 100755 (executable)
@@ -1,5 +1,33 @@
 #!/bin/sh
 
+make_resolv_conf() {
+  echo search $new_domain_name >/etc/resolv.conf
+  for nameserver in $new_domain_name_servers; do
+    echo nameserver $nameserver >>/etc/resolv.conf
+  done
+}
+
+# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
+exit_with_hooks() {
+  exit_status=$1
+  if [ -x /etc/dhclient-exit-hooks ]; then
+    . /etc/dhclient-exit-hooks
+  fi
+# probably should do something with exit status of the local script
+  exit $exit_status
+}
+
+# Invoke the local dhcp client enter hooks, if they exist.
+if [ -x /etc/dhclient-enter-hooks ]; then
+  exit_status=0
+  . /etc/dhclient-enter-hooks
+  # allow the local script to abort processing of this state
+  # local script must set exit_status variable to nonzero.
+  if [ $exit_status -ne 0 ]; then
+    exit $exit_status
+  fi
+fi
+
 if [ x$new_network_number != x ]; then
    echo New Network Number: $new_network_number
 fi
@@ -25,7 +53,7 @@ if [ x$reason = xMEDIUM ]; then
   ifconfig $interface $medium
   ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
   sleep 1
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xPREINIT ]; then
@@ -35,11 +63,11 @@ if [ x$reason = xPREINIT ]; then
   fi
   ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
                broadcast 255.255.255.255 up
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
-  exit 0;
+  exit_with_hooks 0;
 fi
   
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
@@ -89,7 +117,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   for nameserver in $new_domain_name_servers; do
     echo nameserver $nameserver >>/etc/resolv.conf
   done
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
@@ -117,7 +145,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
     route add $alias_ip_address 127.0.0.1
   fi
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xTIMEOUT ]; then
@@ -153,7 +181,7 @@ if [ x$reason = xTIMEOUT ]; then
        rm -f /etc/resolv.conf
       fi
       mv /etc/resolv.conf.std /etc/resolv.conf
-      exit 0
+      exit_with_hooks 0
     fi
   fi
   ifconfig $interface inet -alias $new_ip_address $medium
@@ -169,7 +197,7 @@ if [ x$reason = xTIMEOUT ]; then
   fi
   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                        |sh >/dev/null 2>&1
-  exit 1
+  exit_with_hooks 1
 fi
 
-exit 0
+exit_with_hooks 0
index ec1addf4ddf0588c28cb925c4a2f0a022ac22d59..22697937079b069d0392c6d5fa0f6bc0220c328f 100755 (executable)
@@ -1,5 +1,33 @@
 #!/bin/sh
 
+make_resolv_conf() {
+  echo search $new_domain_name >/etc/resolv.conf
+  for nameserver in $new_domain_name_servers; do
+    echo nameserver $nameserver >>/etc/resolv.conf
+  done
+}
+
+# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
+exit_with_hooks() {
+  exit_status=$1
+  if [ -x /etc/dhclient-exit-hooks ]; then
+    . /etc/dhclient-exit-hooks
+  fi
+# probably should do something with exit status of the local script
+  exit $exit_status
+}
+
+# Invoke the local dhcp client enter hooks, if they exist.
+if [ -x /etc/dhclient-enter-hooks ]; then
+  exit_status=0
+  . /etc/dhclient-enter-hooks
+  # allow the local script to abort processing of this state
+  # local script must set exit_status variable to nonzero.
+  if [ $exit_status -ne 0 ]; then
+    exit $exit_status
+  fi
+fi
+
 if [ x$new_network_number != x ]; then
    echo New Network Number: $new_network_number
 fi
@@ -25,7 +53,7 @@ if [ x$reason = xMEDIUM ]; then
   ifconfig $interface $medium
   ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
   sleep 1
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xPREINIT ]; then
@@ -35,9 +63,13 @@ if [ x$reason = xPREINIT ]; then
   fi
   ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
                broadcast 255.255.255.255 up
-  exit 0
+  exit_with_hooks 0
 fi
 
+if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
+  exit_with_hooks 0
+fi
+  
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
    [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
   if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
@@ -45,8 +77,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
-  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
-   then
+  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
     ifconfig $interface inet -alias $old_ip_address $medium
     route delete $old_ip_address 127.1 >/dev/null 2>&1
     for router in $old_routers; do
@@ -82,11 +113,8 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
     route add $alias_ip_address 127.0.0.1
   fi
-  echo search $new_domain_name >/etc/resolv.conf
-  for nameserver in $new_domain_name_servers; do
-    echo nameserver $nameserver >>/etc/resolv.conf
-  done
-  exit 0
+  make_resolv_conf
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
@@ -114,7 +142,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
     route add $alias_ip_address 127.0.0.1
   fi
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xTIMEOUT ]; then
@@ -142,15 +170,8 @@ if [ x$reason = xTIMEOUT ]; then
        route add $0 $1
        shift; shift
       done
-      echo search $new_domain_name >/etc/resolv.conf.std
-      for nameserver in $new_domain_name_servers; do
-       echo nameserver $nameserver >>/etc/resolv.conf.std
-      done
-      if [ -f /etc/resolv.conf ]; then
-       rm -f /etc/resolv.conf
-      fi
-      mv /etc/resolv.conf.std /etc/resolv.conf
-      exit 0
+      make_resolv_conf
+      exit_with_hooks 0
     fi
   fi
   ifconfig $interface inet -alias $new_ip_address $medium
@@ -166,7 +187,7 @@ if [ x$reason = xTIMEOUT ]; then
   fi
   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                        |sh >/dev/null 2>&1
-  exit 1
+  exit_with_hooks 1
 fi
 
-exit 0
+exit_with_hooks 0
index 52a1885c7ccbfd0c7324554274584b39d7c3b1be..d60feeac90f051188cb9061206609b41ab16566b 100755 (executable)
@@ -1,5 +1,33 @@
 #!/bin/sh  
 
+make_resolv_conf() {
+  echo search $new_domain_name >/etc/resolv.conf
+  for nameserver in $new_domain_name_servers; do
+    echo nameserver $nameserver >>/etc/resolv.conf
+  done
+}
+
+# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
+exit_with_hooks() {
+  exit_status=$1
+  if [ -x /etc/dhclient-exit-hooks ]; then
+    . /etc/dhclient-exit-hooks
+  fi
+# probably should do something with exit status of the local script
+  exit $exit_status
+}
+
+# Invoke the local dhcp client enter hooks, if they exist.
+if [ -x /etc/dhclient-enter-hooks ]; then
+  exit_status=0
+  . /etc/dhclient-enter-hooks
+  # allow the local script to abort processing of this state
+  # local script must set exit_status variable to nonzero.
+  if [ $exit_status -ne 0 ]; then
+    exit $exit_status
+  fi
+fi
+
 if [ x$new_broadcast_address != x ]; then
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
@@ -27,7 +55,7 @@ if [ x$reason = xMEDIUM ]; then
   $ifconfig $interface $medium
   $ifconfig $interface
   sleep 1
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xPREINIT ]; then
@@ -44,11 +72,11 @@ if [ x$reason = xPREINIT ]; then
       $ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
               broadcast 255.255.255.255 up
   fi 
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
-  exit 0;
+  exit_with_hooks 0;
 fi
   
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
@@ -64,7 +92,6 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
@@ -84,7 +111,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   for nameserver in $new_domain_name_servers; do
     echo nameserver $nameserver >>/etc/resolv.conf
   done
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
@@ -98,14 +125,12 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
-                                               |sh >/dev/null 2>&1
   fi
   if [ x$alias_ip_address != x ]; then
     $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
     route add $alias_ip_address 127.0.0.1 1
   fi
-  exit 0
+  exit_with_hooks 0
 fi
 
 if [ x$reason = xTIMEOUT ]; then
@@ -135,15 +160,13 @@ if [ x$reason = xTIMEOUT ]; then
       rm -f /etc/resolv.conf
       ln /etc/resolv.conf.std /etc/resolv.conf
     fi
-    exit 0
+    exit_with_hooks 0
   fi
   $ifconfig $interface inet 0 down
   for router in $old_routers; do
     route delete default $router >/dev/null 2>&1
   done
-  arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
-                                                       |sh >/dev/null 2>&1
-  exit 1
+  exit_with_hooks 1
 fi
 
-exit 0
+exit_with_hooks 0