summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 15:10:01 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 12:03:50 +0200
commit0f5433d4cdb76fff8a4baaae68322bb91f6ce1c5 (patch)
tree1690063d5acf6b0f00e099259347bbed822b62aa
parent[RELEASE] init-scripts-0.3.28 (diff)
downloadinit-scripts-0.3.29.tar.gz
[RELEASE] init-scripts-0.3.29v0.3.29
-rw-r--r--ChangeLog3
-rwxr-xr-xsbin/init.d/network112
-rwxr-xr-xsbin/rc.S70
3 files changed, 155 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index fb97167..fd4351d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2003/12/07 : 0.3.29
+- network : added 'ip arp' ; allow modprobe to fail ; add flush & reload
+- rc.S : ordered mounts & automatic mkdir
2003/11/16 : 0.3.28
- functions : break possible infinite loop in recursive_rmmod
- removed buggy logrotate script
diff --git a/sbin/init.d/network b/sbin/init.d/network
index d138b2c..4a0c318 100755
--- a/sbin/init.d/network
+++ b/sbin/init.d/network
@@ -22,6 +22,11 @@ if [ "$1" = "restart" ]; then
$0 stop "$@"
$0 start "$@"
exit $?
+elif [ "$1" = "reload" ]; then
+ shift
+ $0 flush "$@"
+ $0 start "$@"
+ exit $?
fi
. `dirname $0`/functions
@@ -40,7 +45,26 @@ option multicast boolean_option 1
option shutdown boolean_option
option vrrp multiple_option
-SVC_VARS="addr_list route_list addr_idx route_idx"
+SVC_VARS="addr_list route_list arp_list addr_idx route_idx arp_idx"
+
+
+function do_help {
+ echo "Usage: ${0##*/} <status|start|stop|flush|reload|help>"
+ echo "List of config.rc options (name, type, default value, current value) :"
+ echo
+ echo " - ip addr <address>, arp <ip> <mac>|pub, dhcp, route <dest> <gw> [<args>]"
+ echo " - media auto|{full|fdx|100full|100fdx}|{half|hdx|100half|100hdx}"
+ echo " - duplex {half|full}"
+ echo " - speed {10|100|1000}"
+ echo " - auto {on|off}"
+ echo " - slave <interface*>"
+ echo " - modprobe <module> <arg*>"
+ echo " - lladdr <mac_addr>"
+ echo " - mtu <mtu> ; arp {on|off} ; multicast {on|off} ; shutdown"
+ echo " - vrrp <id|prio|addr|auth_type|pass|garp>"
+ echo
+ exit 1
+}
# changes the negociation parameters for interface $1
# usage: set_media <interface> <media>
@@ -88,8 +112,10 @@ function set_media2 {
function fct_begin_section {
addr_list=( )
+ arp_list=( )
route_list=( )
addr_idx=0
+ arp_idx=0
route_idx=0
}
@@ -103,6 +129,10 @@ function option_ip {
addr_list[$addr_idx]="$*"
addr_idx=$[$addr_idx+1]
;;
+ arp|neigh*)
+ arp_list[$arp_idx]="$*"
+ arp_idx=$[$arp_idx+1]
+ ;;
route)
route_list[$route_idx]="$*"
route_idx=$[$route_idx+1]
@@ -132,7 +162,9 @@ function do_start {
arg=0
while [ $arg -lt ${#opt_modprobe[*]} ]; do
if [ "${opt_modprobe[$arg]}" != "#" ]; then
- modprobe ${opt_modprobe[$arg]} || return 1
+ if ! modprobe ${opt_modprobe[$arg]}; then
+ echo " ==> start $svcname : modprobe ${opt_modprobe[$arg]} failed. Trying anyway."
+ fi
fi
arg=$[$arg+1]
done
@@ -165,16 +197,16 @@ function do_start {
while [ $arg -lt ${#opt_modprobe[*]} ]; do
if [ "${opt_modprobe[$arg]}" != "#" ]; then
if ! modprobe ${opt_modprobe[$arg]}; then
- echo " ==> start $svcname${instname:+[$instname]} : modprobe ${opt_modprobe[$arg]} Failed."
- return 1
+ echo " ==> start $svcname${instname:+[$instname]} : modprobe ${opt_modprobe[$arg]} failed. Trying anyway."
+ # return 1
fi
else
local err # do not merge the assignment here, local sets $? to 0 !
err=`modprobe $instname 2>&1`
if [ $? -gt 0 ]; then
if ! grep -q "^[ ]*$instname:" /proc/net/dev >/dev/null 2>&1; then
- echo " ==> modprobe $instname failed : $err"
- return 1
+ echo " ==> start $svcname[$instname] : modprobe $instname failed : $err. Trying anyway."
+ # return 1
fi
fi
fi
@@ -261,6 +293,24 @@ function do_start {
done
arg=0
+ while [ $arg -lt $arp_idx ]; do
+ local ip mac
+ ip=${arp_list[$arg]%%[ ]*}
+ mac=${arp_list[$arg]#*[ ]}
+
+ # delete annoying pub entries if it exists. We don't use ip neigh here
+ # because it cannot create anything if an incomplete entry exists.
+ arp -i $instname -d $ip pub >/dev/null 2>&1
+
+ if [ "$mac" = "pub" ]; then
+ arp -i $instname -Ds $ip $instname pub
+ else
+ arp -i $instname -s $ip $mac
+ fi
+ arg=$[$arg+1]
+ done
+
+ arg=0
while [ $arg -lt $route_idx ]; do
local dest gw
dest=${route_list[$arg]%%[ ]*}
@@ -359,6 +409,56 @@ function do_stop {
echo " ==> stop $svcname${instname:+[$instname]} : Done."
}
+
+# only flushes addresses, routes routes and sets if down. doesn't remove any module
+function do_flush {
+ local svcname=$1
+ local instname=$2
+ local arg
+
+ if [ -z "$instname" ]; then
+ echo "# Flushing $svcname ..."
+
+ arg=0
+ while [ $arg -lt $route_idx ]; do
+ ip route del ${route_list[$arg]} >/dev/null 2>&1
+ arg=$[$arg+1]
+ done
+ return $?
+ fi
+
+ echo "# Flushing $svcname${instname:+[$instname]} ..."
+
+ if ! do_status $svcname $instname > /dev/null 2>&1; then
+ # vlan interfaces must disappear
+ if [ -n "${instname//*.*/}" ] || ! ip link show $instname >/dev/null 2>&1; then
+ echo " ==> flush $svcname${instname:+[$instname]} : already flushed."
+ return 0
+ fi
+ fi
+
+ # we may have to kill dhcpcd
+ arg=0
+ while [ $arg -lt $addr_idx ]; do
+ if [ "${addr_list[$arg]}" = "dhcp" ]; then
+ local proc
+ for proc in $(svc_pidof dhcpcd) ; do
+ if grep -qs $instname /proc/$proc/cmdline ; then kill $proc ; fi
+ done
+ fi
+ arg=$[$arg+1]
+ done
+
+ ip addr flush dev $instname >/dev/null 2>&1
+ ip link set $instname down >/dev/null 2>&1
+
+ # a dot in an interface name means physical_if.vlanid
+ # We have to remove the interface now.
+ [ -z "${instname//*.*/}" ] && vconfig rem $instname >/dev/null
+
+ echo " ==> flush $svcname${instname:+[$instname]} : Done."
+}
+
#### these are the old versions. The slave mechanism should be checked.
_start_if() {
diff --git a/sbin/rc.S b/sbin/rc.S
index 7b62334..c07284d 100755
--- a/sbin/rc.S
+++ b/sbin/rc.S
@@ -1,5 +1,31 @@
#!/bin/sh
+function build_var {
+ # check whether /var is already mounted read-write. If not, we'll do
+ # it because it's unacceptable to work in read-only mode !
+ if touch /var/.$BOOTID >/dev/null 2>&1; then
+ rm -f /var/.$BOOTID >/dev/null 2>&1
+ else
+ echo
+ echo "WARNING: Mounting /var as tmpfs !"
+ umount /var >/dev/null 2>&1
+ mount -o mode=755 -t tmpfs /var /var
+ fi
+
+ # Create /var directories if they don't exist
+ if [ ! -d /var/tmp ] ; then mkdir -m 1777 /var/tmp ; fi
+ if [ ! -d /var/run ] ; then mkdir /var/run ; fi
+ if [ ! -d /var/state ] ; then mkdir /var/state ; fi
+ if [ ! -d /var/lib ] ; then mkdir /var/lib ; fi
+ if [ ! -d /var/spool ] ; then mkdir /var/spool ; fi
+ if [ ! -d /var/log ] ; then mkdir /var/log ; chown root:log /var/log; chmod 2751 /var/log; fi
+ if [ ! -d /var/cache ] ; then mkdir /var/cache ; fi
+ if [ ! -d /var/empty ] ; then mkdir /var/empty ; chmod 100 /var/empty; fi
+ if [ ! -d /var/adm/. ] ; then ln -s log /var/adm ; fi
+
+ sync
+}
+
umask 022
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -73,32 +99,28 @@ if [ $? -gt 1 ] ; then
else
# mount file systems in fstab (and create an entry for /)
# but not NFS because TCP/IP is not yet configured
- mount -nat nonfs,noproc
-fi
-
-
-# check whether /var is already mounted read-write. If not, we'll do
-# it because it's unacceptable to work in read-only mode !
-if touch /var/.$BOOTID >/dev/null 2>&1; then
- rm -f /var/.$BOOTID >/dev/null 2>&1
-else
- echo "WARNING: Mounting /var as tmpfs !"
- umount /var >/dev/null 2>&1
- mount -o mode=755 -t tmpfs /var /var
+ mount -nafvt nonfs,noproc 2>/dev/null|grep '^/'| while read dev ON dir rest;do
+ echo -n "Mounting $dev on $dir... "
+ if [ ! -d "$dir" ]; then
+ subdir=${dir%/*}
+ while ! mkdir -p "$dir" 2>/dev/null && [ -n "$subdir" ]; do
+ if grep -q "^/[^ ]* $subdir " /proc/mounts; then
+ mount -wo remount "$subdir"
+ mkdir -p "$dir" 2>/dev/null
+ break
+ elif [ "$subdir" = "/var" ]; then
+ # we can do it now because we're now certain that
+ # no other file-system will handle it
+ build_var
+ fi
+ subdir=${subdir%/*}
+ done
+ fi
+ mount -n $dir && echo "done."
+ done
fi
-# Create /var directories if they don't exist
-if [ ! -d /var/tmp ] ; then mkdir -m 1777 /var/tmp ; fi
-if [ ! -d /var/run ] ; then mkdir /var/run ; fi
-if [ ! -d /var/state ] ; then mkdir /var/state ; fi
-if [ ! -d /var/lib ] ; then mkdir /var/lib ; fi
-if [ ! -d /var/spool ] ; then mkdir /var/spool ; fi
-if [ ! -d /var/log ] ; then mkdir /var/log ; chown root:log /var/log; chmod 2751 /var/log; fi
-if [ ! -d /var/cache ] ; then mkdir /var/cache ; fi
-if [ ! -d /var/empty ] ; then mkdir /var/empty ; chmod 100 /var/empty; fi
-if [ ! -d /var/adm/. ] ; then ln -s log /var/adm ; fi
-
-sync
+build_var
# check whether /tmp is already mounted read-write. If not, we'll do
# it because it's unacceptable to work in read-only mode !