summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorBenedikt Boehm <hollow@gentoo.org>2005-10-09 08:31:20 +0000
committerBenedikt Boehm <hollow@gentoo.org>2005-10-09 08:31:20 +0000
commit53c0ee2f8b484270b6ad60d53c5f7247e9a428db (patch)
tree693a49c846b08b89cc2c784dc692dd44904ed2ec /sbin
parentRefreshing baselayout-vserver with revision 1560 from baselayout. (diff)
downloadbaselayout-vserver-53c0ee2f8b484270b6ad60d53c5f7247e9a428db.tar.gz
baselayout-vserver-53c0ee2f8b484270b6ad60d53c5f7247e9a428db.tar.bz2
baselayout-vserver-53c0ee2f8b484270b6ad60d53c5f7247e9a428db.zip
add back net services
svn path=/baselayout-vserver/trunk/; revision=52
Diffstat (limited to 'sbin')
-rwxr-xr-xsbin/MAKEDEV637
-rwxr-xr-xsbin/functions.sh1
-rwxr-xr-xsbin/rc17
-rwxr-xr-xsbin/rc-services.sh115
-rwxr-xr-xsbin/rc-update10
-rwxr-xr-xsbin/runscript.sh79
6 files changed, 639 insertions, 220 deletions
diff --git a/sbin/MAKEDEV b/sbin/MAKEDEV
index 54901b2..832965d 100755
--- a/sbin/MAKEDEV
+++ b/sbin/MAKEDEV
@@ -1,6 +1,5 @@
#! /bin/sh -
-
-RCSID='$Id: MAKEDEV 560 2004-09-19 05:39:28Z vapier $'
+# $Id: MAKEDEV 1421 2005-08-23 23:56:23Z vapier $
#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
# Customisation:
@@ -14,9 +13,8 @@ RCSID='$Id: MAKEDEV 560 2004-09-19 05:39:28Z vapier $'
private=" root root 0600"
system=" root root 0660"
kmem=" root kmem 0640"
- tty=" root tty 0660" # Perms was 0666
+ tty=" root tty 0666"
cons=" root tty 0600"
- vcs=" root root 0600"
dialout=" root dialout 0660"
dip=" root dip 0660"
mouse=" root root 0660"
@@ -28,9 +26,8 @@ printer=" root lp 0660"
tape=" root tape 0660"
audio=" root audio 0660"
video=" root video 0660"
- fb=" root video 0620"
- ibcs2=" root root 0660" # Perms was 0666
-scanner=" root root 0660" # Perms was 0666
+ ibcs2=" root root 0666"
+scanner=" root root 0666"
coda=" root root 0600"
ipsec=" root root 0200"
readable=" root root 0444"
@@ -47,20 +44,40 @@ major_lp=6
#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
+# try to do the right things if udev is running
+if [ "$WRITE_ON_UDEV" ]; then
+ :
+elif [ -d /dev/.static/dev/ ] && [ "`pwd`" = /dev ] && [ -e /proc/mounts ] \
+ && grep -qE '^[^ ]+ /dev/\.static/dev' /proc/mounts; then
+ cd /dev/.static/dev/
+elif [ -d /.dev/ ] && [ "`pwd`" = /dev ] && [ -e /proc/mounts ] \
+ && grep -qE '^[^ ]+ /\.dev' /proc/mounts; then
+ cd /.dev/
+elif [ -d .udevdb/ ] && [ "`pwd`" = /dev ]; then
+ echo ".udevdb presence implies active udev. Aborting MAKEDEV invocation."
+ # use exit 0, not 1, so postinst scripts don't fail on this
+ exit 0
+fi
+
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
+
# don't stomp on devfs users
if [ -c .devfsd ]
then
- echo ".devfsd presence implies active DevFS. Aborting MAKEDEV invocation."
- # use exit 0, not 1, so postinst scripts don't fail on this
- exit 0
+ echo ".devfsd presence implies active DevFS. Aborting MAKEDEV invocation."
+ # use exit 0, not 1, so postinst scripts don't fail on this
+ exit 0
fi
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
-# make sure we are not in /
-if [ "`pwd`" = "/" ]; then
- echo "Running MAKEDEV in your root filesystem is a VERY BAD IDEA."
- exit 0
-fi
+# don't stomp on non-Linux users
+if [ "$(uname -s)" != "Linux" ]
+then
+ echo "Results undefined on non-Linux systems, aborting MAKEDEV invocation."
+ # use exit 0, not 1, so postinst scripts don't fail on this
+ exit 0
+fi
#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
@@ -85,7 +102,8 @@ done
if [ "$opt_V" ]
then
- echo "$RCSID"
+ echo "This is MAKEDEV based on Debian's makedev_2.3.1-78."
+ echo "See the MAKEDEV(8) manpage for more information."
exit 0
fi
@@ -93,23 +111,39 @@ opts="${opt_n:+-n} ${opt_v:+-v} ${opt_d:+-d}"
#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
+devicename () { # translate device names to something safe
+ echo "$*" | sed -e 's/[^A-Za-z0-9_]/_/g'
+}
+
makedev () { # usage: makedev name [bcu] major minor owner group mode
if [ "$opt_v" ]
then if [ "$opt_d" ]
then echo "delete $1"
- else echo "create $1 $2 $3 $4 $5:$6 $7"
+ else echo "create $1 $2 $3 $4 $5:$6 $7"
fi
fi
+ # missing parameters are a bug - bail - should we do an exit 1 here?
+ case :$1:$2:$3:$4:$5:$6:$7: in
+ *::*) echo "Warning: MAKEDEV $@ is missing parameter(s)." >&2;;
+ esac
if [ ! "$opt_n" ]
- then if [ "$opt_d" ]
+ then
+ if [ "$opt_d" ]
then
rm -f $1
else
rm -f $1-
- mknod $1- $2 $3 $4 &&
- chown $5:$6 $1- &&
- chmod $7 $1- &&
- mv $1- $1
+ if mknod $1- $2 $3 $4 &&
+ chown $5:$6 $1- &&
+ chmod $7 $1- &&
+ mv $1- $1
+ then
+ : # it worked
+ else
+ # Didn't work, clean up any mess...
+ echo "makedev $@: failed"
+ rm -f $1-
+ fi
fi
fi
}
@@ -142,13 +176,13 @@ strip () {
eval echo "\${1% $2 *} \${1#* $2 }"
}
first () {
- eval echo "\${1:0:1}"
+ echo "${1%%?}"
}
second () {
- eval echo "\${1:1:1}"
+ echo "${1##?}"
}
substr () {
- echo $1 | cut -c $2
+ echo $1 | dd bs=1 count=1 skip=$(( $2 - 1 )) 2> /dev/null
}
#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
@@ -159,14 +193,15 @@ then
echo "$0: warning: can't read $procfs/devices" >&2
else
exec 3<$procfs/devices
- while read major device <&3
+ while read major device extra <&3
do
device=`echo $device | sed 's#/.*##'`
case "$major" in
Character|Block|'')
;;
*)
- eval "major_${device/-/_}=$major"
+ safedevname=`devicename $device`
+ eval "major_$safedevname=$major"
devices="$devices $device"
;;
esac
@@ -176,11 +211,12 @@ fi
Major () {
device=$2
+ devname=`devicename $1`
if [ "$opt_d" ]
then
echo -1 # don't care
else
- eval echo \${major_${1/-/_}:-\${device:?\"unknown major number for $1\"}}
+ eval echo \${major_$devname:-\${device:?\"unknown major number for $1\"}}
fi
}
@@ -199,6 +235,10 @@ cvt () {
ide3) echo hdg hdh ;;
ide4) echo hdi hdj ;;
ide5) echo hdk hdl ;;
+ ide6) echo hdm hdn ;;
+ ide7) echo hdo hdp ;;
+ ide8) echo hdq hdr ;;
+ ide9) echo hds hdt ;;
sd) echo sda sdb sdc sdd ;;
dasd) (for d in a b c d e f g h i j k l m \
n o p q r s t u v w x y z ; do
@@ -242,18 +282,24 @@ cvt () {
microcode) echo microcode ;;
ipmi|ipmikcs) echo ipmi ;;
fb) echo fb ;;
- nb) echo nb0 nb1 ;;
+ nb|drbd) echo nb0 nb1 nb2 nb3 nb4 nb5 nb6 nb7;;
netlink) echo netlink ;;
tap) echo netlink ;;
hamradio) echo hamradio ;;
snd) ;;
ptm) ;;
pts) ;;
- ttyS) echo ttyS0 ttyS1 ttyS2 ttyS3 ;;
+ ttyB) (for l in 0 1 2 3 4 5 6 7 ; do
+ echo -n ttyB$l " "
+ done) ; echo
+ ;;
+ ttyS) echo ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ;;
ttyI) echo ttyI0 ttyI1 ttyI2 ttyI3 ;;
- ircomm|irlpt) echo irda ;;
+ ircomm|irlpt) irda ;;
ppp) echo ppp ;;
usb) echo usb ;;
+ dpt_i2o) echo dpti ;;
+ bluetooth) echo bluetooth ;;
lvm) ;; # taken care of by LVM userspace tools
ramdisk) echo ram ;;
*) echo "$0: don't know what \"$1\" is" >&2 ;;
@@ -262,70 +308,28 @@ cvt () {
done
}
-for arg
+get_arch() {
+ local a=`uname -m`
+ case `uname -m` in
+ arm*) echo arm;;
+ i?86) echo i386;;
+ ppc*) echo powerpc;;
+ s390*) echo s390;;
+ sh*) echo sh;;
+ x86_64) echo i386;;
+ # alpha|hppa|ia64|m68k|mips|sparc
+ *) echo $a;;
+ esac
+}
+
+for arg in $*
do
# case `cvt $arg` in
case $arg in
generic)
- if [ -n "`which dpkg 2> /dev/null`" ]
- then
- # pick the right generic-<arch> using dpkg's knowledge
- case `dpkg --print-installation-architecture` in
- alpha)
- $0 $opts generic-alpha
- ;;
- arm)
- $0 $opts generic-arm
- ;;
- hppa)
- $0 $opts generic-hppa
- ;;
- i386)
- $0 $opts generic-i386
- ;;
- ia64)
- $0 $opts generic-ia64
- ;;
- m68k)
- $0 $opts generic-m68k
- ;;
- mips)
- $0 $opts generic-mips
- ;;
- mipsel)
- $0 $opts generic-mipsel
- ;;
- powerpc)
- $0 $opts generic-powerpc
- ;;
- s390)
- $0 $opts generic-s390
- ;;
- sparc)
- $0 $opts generic-sparc
- ;;
- *)
- echo "$0: no support for generic on this arch" >&2
- exit 1
- ;;
- esac
- else
- $0 $opts std
- $0 $opts fd
- $0 $opts fd0 fd1
- $0 $opts hda hdb
- $0 $opts xda xdb
- $0 $opts sda sdb
- $0 $opts pty
- $0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
- $0 $opts busmice
- $0 $opts lp
- $0 $opts par
- fi
+ $0 $opts generic-`get_arch`
;;
generic-alpha)
- export MDARCH="alpha"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -337,15 +341,15 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts busmice
$0 $opts lp
$0 $opts par
$0 $opts audio
$0 $opts fb
+ $0 $opts dac960
;;
generic-arm)
- export MDARCH="arm"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -357,25 +361,27 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts busmice
+ makedev sunmouse c 10 6 $mouse
$0 $opts lp
$0 $opts par
$0 $opts audio
$0 $opts fb
;;
generic-hppa)
- export MDARCH="hppa"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
+ $0 $opts hda hdb hdc hdd
$0 $opts sda sdb sdc sdd
$0 $opts scd0 scd1
$0 $opts st0 st1
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
+ $0 $opts ttyB0 ttyB1 ttyB2 ttyB3 ttyB4 ttyB5 ttyB6 ttyB7
$0 $opts busmice
$0 $opts lp
$0 $opts par
@@ -384,7 +390,6 @@ do
$0 $opts rtc
;;
generic-i386)
- export MDARCH="i386"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -396,23 +401,23 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts busmice
+ $0 $opts input
$0 $opts lp
$0 $opts par
$0 $opts audio
$0 $opts fb
$0 $opts isdn-io eda edb sonycd mcd mcdx cdu535
- $0 $opts optcd sjcd cm206cd gscd
- $0 $opts lmscd sbpcd aztcd bpcd dac960 ida ataraid cciss
+ $0 $opts optcd sjcd cm206cd gscd
+ $0 $opts lmscd sbpcd aztcd bpcd dac960 dpti ida ataraid cciss
+ $0 $opts i2o.hda i2o.hdb i2o.hdc i2o.hdd
;;
generic-ia64)
- export MDARCH="ia64"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
$0 $opts hda hdb hdc hdd
- $0 $opts xda xdb
$0 $opts sda sdb sdc sdd
$0 $opts scd0 scd1
$0 $opts st0 st1
@@ -421,6 +426,7 @@ do
$0 $opts console
$0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5
$0 $opts busmice
+ $0 $opts input
$0 $opts lp
$0 $opts par
$0 $opts audio
@@ -428,17 +434,17 @@ do
$0 $opts efirtc
;;
generic-m68k)
- export MDARCH="m68k"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
$0 $opts hda hdb hdc hdd
$0 $opts sda sdb sdc sdd
+ $0 $opts scd0 scd1
$0 $opts sg
$0 $opts ada adb adc add ade adf
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS5
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5
$0 $opts m68k-mice
$0 $opts lp
$0 $opts par
@@ -447,7 +453,6 @@ do
$0 $opts fb
;;
generic-mips)
- export MDARCH="mips"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -458,7 +463,7 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts lp
$0 $opts par
$0 $opts audio
@@ -466,7 +471,6 @@ do
$0 $opts busmice
;;
generic-mipsel)
- export MDARCH="mipsel"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -477,7 +481,7 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts lp
$0 $opts par
$0 $opts audio
@@ -485,7 +489,6 @@ do
$0 $opts rtc
;;
generic-powerpc)
- export MDARCH="powerpc"
$0 $opts std
$0 $opts fd
$0 $opts fd0 fd1
@@ -496,7 +499,7 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts busmice
$0 $opts m68k-mice
$0 $opts input
@@ -510,7 +513,6 @@ do
$0 $opts isdn-io
;;
generic-s390)
- export MDARCH="s390"
$0 $opts std
$0 $opts fd
$0 $opts dasda dasdb dasdc dasdd dasde dasdf dasdg dasdh \
@@ -521,10 +523,29 @@ do
$0 $opts consoleonly
$0 $opts rtc
;;
+ generic-sh)
+ $0 $opts std
+ $0 $opts fd
+ $0 $opts fd0 fd1
+ $0 $opts hda hdb
+ $0 $opts sda sdb sdc sdd
+ $0 $opts scd0 scd1
+ $0 $opts st0 st1
+ $0 $opts sg
+ $0 $opts pty
+ $0 $opts console
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
+ $0 $opts ttySC0 ttySC1 ttySC2 ttySC3
+ $0 $opts lp
+ $0 $opts par
+ $0 $opts audio
+ $0 $opts fb
+ $0 $opts rtc
+ ;;
generic-sparc)
- export MDARCH="sparc"
$0 $opts std
- $0 $opts fd0-bare fd1-bare
+ $0 $opts fd
+ $0 $opts fd0 fd1
$0 $opts hda hdb hdc hdd
$0 $opts sda sdb sdc sdd
$0 $opts scd0 scd1
@@ -532,17 +553,16 @@ do
$0 $opts sg
$0 $opts pty
$0 $opts console
- $0 $opts ttyS0 ttyS1 ttyS2 ttyS3
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4
$0 $opts busmice
$0 $opts fb
$0 $opts rtc
makedev kbd c 11 0 $cons
makedev sunmouse c 10 6 $mouse
symlink mouse sunmouse
- makedev openprom c 10 139 $mouse
+ makedev openprom c 10 139 root root 0664
;;
generic-vserver)
- export MDARCH="vserver"
makedev null c 1 3 $public
makedev zero c 1 5 $public
makedev full c 1 7 $public
@@ -558,6 +578,10 @@ do
$0 $opts fd
$0 $opts ptmx
;;
+ generic-*)
+ echo "$0: no support for generic on this arch" >&2
+ exit 1
+ ;;
local)
$0.local $opts
;;
@@ -580,7 +604,7 @@ do
$0 $opts bc
;;
scc)
- for unit in 0 1 2 3 4 5 6 7
+ for unit in 0 1 2 3 4 5 6 7
do
makedev scc$unit c 34 $unit $system
done
@@ -611,22 +635,22 @@ do
makedev initrd b 1 250 $disk
;;
raw)
- makedev raw c 162 0 $disk
- symlink rawctl raw
+ makedev rawctl c 162 0 $disk
+ mkdir -p raw
for i in 1 2 3 4 5 6 7 8; do
- makedev raw$i c 162 $i $disk
+ makedev raw/raw$i c 162 $i $disk
done
;;
consoleonly)
makedev tty0 c 4 0 $cons
# new kernels need a device, old ones a symlink... sigh
- kern_rev1=`uname -r | awk -F'.' '{print $1}'`
- kern_rev2=`uname -r | awk -F'.' '{print $2}'`
+ kern_rev1=`uname -r | sed -e 's@^\([^.]*\)\..*@\1@'`
+ kern_rev2=`uname -r | sed -e 's@^[^.]*\.\([^.]*\)\..*@\1@'`
if [ $kern_rev1 -gt 2 ]
then
makedev console c 5 1 $cons
else
- if [ $kern_rev1 -eq 2 -a $kern_rev2 -ge 1 ]
+ if [ $kern_rev1 -eq 2 ] && [ $kern_rev2 -ge 1 ]
then
makedev console c 5 1 $cons
else
@@ -637,34 +661,22 @@ do
console)
$0 $opts consoleonly
major=`Major vcs 7` # not fatal
- [ "$major" ] && makedev vcs0 c $major 0 $vcs
+ [ "$major" ] && makedev vcs0 c $major 0 $cons
symlink vcs vcs0
- [ "$major" ] && makedev vcsa0 c $major 128 $vcs
+ [ "$major" ] && makedev vcsa0 c $major 128 $cons
symlink vcsa vcsa0
# individual vts
line=1
- while [ $line -le $MAXVT -a $line -le 63 ]
+ while [ $line -le $MAXVT ] && [ $line -le 63 ]
do
- makedev tty$line c 4 $line $tty
- [ "$major" ] && makedev vcs$line c $major $line $vcs
- [ "$major" ] && makedev vcsa$line c $major `math $line + 128` $vcs
+ makedev tty$line c 4 $line $cons
+ [ "$major" ] && makedev vcs$line c $major $line $cons
+ [ "$major" ] && makedev vcsa$line c $major `math $line + 128` $cons
line=`math $line + 1`
done
;;
adb)
- myarch=
-
- if [ -n "`which dpkg 2> /dev/null`" ]
- then
- # pick the right arch device using dpkg's knowledge
- myarch="`dpkg --print-installation-architecture`"
-
- elif [ -n "${MDARCH}" ]
- then
- myarch="${MDARCH}"
- fi
-
- case $myarch in
+ case `get_arch` in
powerpc)
# ADB bus devices (char)
makedev adb c 56 0 $mouse
@@ -688,18 +700,35 @@ do
raw1394)
makedev raw1394 c 171 0 $disk
;;
+ video1394)
+ rm -f video1394
+ mkdir -p video1394
+ for i in `seq 0 15`
+ do
+ makedev video1394/$i c 171 `math 16 + $i` $video
+ done
+ ;;
nvram)
makedev nvram c 10 144 $mouse
;;
tty[1-9]|tty[1-5][0-9]|tty[6][0-3])
line=`suffix $arg tty`
- makedev tty$line c 4 $line $tty
+ makedev tty$line c 4 $line $cons
;;
ttyS[0-9]|ttyS[1-5][0-9]|ttyS[6][0-3])
line=`suffix $arg ttyS`
minor=`math 64 + $line`
makedev ttyS$line c 4 $minor $dialout
;;
+ ttySC[0-3])
+ line=`suffix $arg ttySC`
+ minor=`math 8 + $line`
+ makedev ttySC$line c 204 $minor $dialout
+ ;;
+ ttyB[0-7])
+ minor=`suffix $arg ttyB`
+ makedev ttyB$minor c 11 $minor $dialout
+ ;;
pty[a-ep-z])
bank=`suffix $arg pty`
base=`index pqrstuvwxyzabcde $bank`
@@ -727,7 +756,7 @@ do
major1=`Major ttyC 19` || continue
#major2=`Major cub 20` || continue
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
do
makedev ttyC$i c $major1 $i $dialout
#makedev cub$i c $major2 $i $dialout
@@ -916,31 +945,27 @@ do
;;
ubd)
major=98
- minor=0
- until [ $minor -gt 255 ]
+ for devicenum in 0 1 2 3 4 5 6 7
do
- makedev ubd$minor b $major $minor $disk
- minor=`math $minor + 1`
+ device=ubd`substr abcdefgh $(($devicenum + 1))`
+ baseminor=`math $devicenum \* 16`
+ makedev $device b $major $baseminor $disk
+ for partition in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ minor=`math $baseminor + $partition`
+ makedev $device$partition b $major $minor $disk
+ done
done
;;
fb)
for i in 0 1 2 3 4 5 6 7
do
- makedev fb$i c 29 `math 32 \* $i` $fb
- makedev fb${i}current c 29 `math 32 \* $i` $fb
- makedev fb${i}autodetect c 29 `math 32 \* $i + 1` $fb
+ makedev fb$i c 29 $i $video
done
;;
fb[0-7])
dev=`suffix $arg fb`
- base=`math 32 \* $dev`
- makedev fb$dev c 29 $base $fb
- makedev fb${dev}current c 29 $base $fb
- makedev fb${dev}autodetect c 29 `math $base + 1` $fb
- for i in 0 1 2 3 4 5 6 7
- do
- makedev fb${dev}user$i c 29 `math $base + 24 + $i` $fb
- done
+ makedev fb$dev c 29 $dev $video
;;
netlink|tap|tap[0-9]|tap1[0-5])
makedev route c 36 0 $coda
@@ -951,6 +976,10 @@ do
makedev tap$i c 36 `math $i + 16` $coda
done
;;
+ tun)
+ mkdir -p net
+ makedev net/tun c 10 200 $system
+ ;;
lp)
major=`Major lp 6` || continue
makedev ${arg}0 c $major 0 $printer
@@ -1010,7 +1039,7 @@ do
major=`Major $arg 10` || continue
makedev $arg c $major 175 $video
;;
- intel_rng)
+ hwrng)
major=`Major $arg 10` || continue
makedev $arg c $major 183 $private
;;
@@ -1035,6 +1064,9 @@ do
makedev irlpt$i c 161 `math $i + 16` $printer
done
;;
+ irnet)
+ makedev irnet c 10 187 $system
+ ;;
misc)
major=`Major mouse 10` || continue
makedev logibm c $major 0 $mouse
@@ -1057,7 +1089,7 @@ do
makedev exttrp c $major 133 $mouse
makedev apm_bios c $major 134 $mouse
makedev rtc c $major 135 $mouse
- makedev openprom c $major 139 $mouse
+ makedev openprom c $major 139 root root 0664
makedev relay8 c $major 140 $mouse
makedev relay16 c $major 141 $mouse
makedev msr c $major 142 $mouse
@@ -1068,18 +1100,31 @@ do
makedev mergemem c $major 153 $mouse
makedev pmu c $major 154 $mouse
;;
- smapi|thinkpad)
+ pmu)
+ major=`Major mouse 10` || continue
+ makedev pmu c $major 154 $mouse
+ ;;
+ thinkpad)
major=`Major mouse 10` || continue
- makedev smapi c $major 170 $mouse
- symlink thinkpad smapi
+ mkdir -p thinkpad
+ makedev thinkpad/thinkpad c $major 170 $mouse
;;
- rtc)
+ rtc)
major=`Major mouse 10` || continue
makedev rtc c $major 135 $mouse
;;
efirtc)
major=`Major mouse 10` || continue
makedev efirtc c $major 136 $mouse
+ ;;
+ mwave)
+ makedev mwave c 10 219 $mouse
+ ;;
+ systrace)
+ makedev systrace c 10 226 $private
+ ;;
+ uinput)
+ makedev input/uinput c 10 223 $mouse
;;
js)
major=`Major Joystick 13` || continue
@@ -1089,16 +1134,6 @@ do
makedev djs$unit c $major `math $unit + 128` $readable
done
;;
- fd[0-7]-bare)
- sarg="${arg%-bare}"
- major=`Major fd 2` || continue
- base=`suffix $sarg fd`
- if [ $base -ge 4 ]
- then
- base=`math $base + 124`
- fi
- makedev ${sarg} b $major $base $floppy
- ;;
fd[0-7])
major=`Major fd 2` || continue
base=`suffix $arg fd`
@@ -1217,6 +1252,58 @@ do
makedev hd$unit$part b $major $(( $base + $part )) $disk
done
;;
+ hd[m-n])
+ major=`Major ide6 88` || continue
+ unit=`suffix $arg hd`
+ base=`index mn $unit`
+ base=`math $base \* 64`
+ makedev hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ do
+ makedev hd$unit$part b $major $(( $base + $part )) $disk
+ done
+ ;;
+ hd[o-p])
+ major=`Major ide7 89` || continue
+ unit=`suffix $arg hd`
+ base=`index op $unit`
+ base=`math $base \* 64`
+ makedev hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ do
+ makedev hd$unit$part b $major $(( $base + $part )) $disk
+ done
+ ;;
+ hd[q-r])
+ major=`Major ide8 90` || continue
+ unit=`suffix $arg hd`
+ base=`index qr $unit`
+ base=`math $base \* 64`
+ makedev hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ do
+ makedev hd$unit$part b $major $(( $base + $part )) $disk
+ done
+ ;;
+ hd[s-t])
+ major=`Major ide9 91` || continue
+ unit=`suffix $arg hd`
+ base=`index st $unit`
+ base=`math $base \* 64`
+ makedev hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ do
+ makedev hd$unit$part b $major $(( $base + $part )) $disk
+ done
+ ;;
+ ub|uba)
+ major=180
+ makedev uba b $major 0 $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ makedev uba$part b $major $part $disk
+ done
+ ;;
ht0)
major=`Major ht0 37` || continue
# Only one IDE tape drive is currently supported; ht0.
@@ -1282,6 +1369,58 @@ do
minor=$(( $base + $part ))
makedev sd$unit$part b $major $minor $disk
done
+ ;;
+ i2o.hd[a-z])
+ [ -d i2o ] || {
+ mkdir i2o
+ chown root:root i2o
+ chmod 755 i2o
+ [ -e i2o/ctl ] || makedev i2o/ctl c 10 166 $disk
+ }
+ unit=`suffix $arg i2o.hd`
+ base=`index abcdefghijklmnopqrstuvwxyz $unit`
+ base=$(( $base * 16 ))
+ if [ $base -lt 256 ]; then
+ major=80
+ else
+ major=81
+ base=$(( $base - 256 ))
+ fi
+ makedev i2o/hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ minor=$(( $base + $part ))
+ makedev i2o/hd$unit$part b $major $minor $disk
+ done
+ ;;
+ i2o.hd[a-d][a-z])
+ [ -d i2o ] || {
+ mkdir i2o
+ chown root:root i2o
+ chmod 755 i2o
+ [ -e i2o/ctl ] || makedev i2o/ctl c 10 166 $disk
+ }
+ unit=`suffix $arg i2o.hd`
+ unitmaj=`first $unit`
+ unitmin=`second $unit`
+ basemaj=`index Xabcd $unitmaj`
+ basemin=`index abcdefghijklmnopqrstuvwxyz $unitmin`
+ basemaj=`math $basemaj \* 416`
+ basemin=`math $basemin \* 16`
+ base=`math $basemaj + $basemin`
+ basemaj=`math $base / 256`
+ base=`math $base % 256`
+ major=`math basemaj \+ 80`
+ if [ $major -gt 87 ]; then
+ echo "$0: don't know how to make device \"$arg\"" >&2
+ exit 0
+ fi
+ makedev i2o/hd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ minor=$(( $base + $part ))
+ makedev i2o/hd$unit$part b $major $minor $disk
+ done
;;
dasd[a-z])
major=`Major dasd 94` || continue
@@ -1295,9 +1434,7 @@ do
base=$(( $base - 256 ))
fi
makedev dasd$unit b $major $base $disk
- # Not yet implemented. (Feb. 8, 2001)
- # for part in 1 2 3
- for part in 1
+ for part in 1 2 3
do
minor=$(( $base + $part ))
makedev dasd$unit$part b $major $minor $disk
@@ -1320,6 +1457,7 @@ do
do
$0 $opts dac960.$ctr
done
+ makedev dac960_gam c 10 252 $disk
;;
dac960.[0-7])
[ -d rd ] || {
@@ -1342,6 +1480,14 @@ do
done
done
;;
+ dpti)
+ major=151
+ for ld in 1 2 3 4 5 6 7
+ do
+ minor=`math $ld -1`
+ makedev dpti${ld} c $major $minor $disk
+ done
+ ;;
ataraid)
for ctr in 0 1 2 # 3 4 5 6 7
do
@@ -1354,16 +1500,16 @@ do
chown root:root ataraid
chmod 755 ataraid
}
- unit=`suffix $arg ataraid.`
- major=114
- minor=`math $unit \* 16`
- makedev ataraid/d${unit} b $major $minor $disk
- for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- do
- minor=`math $minor + 1`
- makedev ataraid/d${unit}p$part b $major $minor $disk
- done
- ;;
+ unit=`suffix $arg ataraid.`
+ major=114
+ minor=`math $unit \* 16`
+ makedev ataraid/d${unit} b $major $minor $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ minor=`math $minor + 1`
+ makedev ataraid/d${unit}p$part b $major $minor $disk
+ done
+ ;;
ida)
for ctr in 0 1 2 # 3 4 5 6 7
do
@@ -1437,6 +1583,10 @@ do
makedev loop$part b 7 $part $disk
done
;;
+ loop[0-9]|loop[1-9][0-9]|loop1[0-9][0-9]|loop2[0-4][0-9]|loop25[0-5])
+ minor=`suffix $arg loop`
+ makedev loop$minor b 7 $minor $disk
+ ;;
md)
major=`Major md 9` || continue
for part in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -1511,7 +1661,7 @@ do
major=`Major sr 11` || continue
unit=`suffix $arg scd`
makedev scd$unit b $major $unit $cdrom
- ln -f scd$unit sr$unit
+ symlink sr$unit scd$unit
;;
ttyI[0-9]|ttyI[1-5][0-9]|ttyI[6][0-3])
major=43
@@ -1612,7 +1762,7 @@ do
makedev ${arg}0 b $major 0 $cdrom
;;
pcd)
- for unit in 0 1 2 3
+ for unit in 0 1 2 3
do
makedev pcd$unit b 46 $unit $cdrom
done
@@ -1629,8 +1779,9 @@ do
cfs|coda)
makedev cfs0 c 67 0 $private
;;
- xfs|arla)
+ xfs|nnpfs|arla)
makedev xfs0 c 103 0 $private
+ makedev nnpfs0 c 103 0 $private
;;
logiscan)
major=`Major logiscan` || continue
@@ -1722,7 +1873,7 @@ do
# devices might be good, but 8 should suffice for now
major=`Major i2c 89` || continue
minor=0
- until [ $minor -gt 7 ]
+ until [ $minor -gt 7 ]
do
makedev i2c-$minor c $major $minor $private
minor=`math $minor + 1`
@@ -1825,6 +1976,47 @@ do
makedev comedi$minor c $major $minor $public
done
;;
+ tilp)
+ for i in `seq 0 7`
+ do
+ makedev tipar$i c 115 $i $printer
+ makedev tiser$i c 115 `math 8 + $i` $dialout
+ done
+ for i in `seq 0 31`
+ do
+ makedev tiusb$i c 115 `math 16 + $i` $dialout
+ done
+ ;;
+ dvb)
+ # check if kernel-version is >= 2.6.8, if yes, create dvb-devices with
+ # major-number 212, in the other case 250
+
+ kern_rev1=`uname -r | sed -e 's@^\([^.]*\)\..*@\1@'`
+ kern_rev2=`uname -r | sed -e 's@^[^.]*\.\([^.]*\)\..*@\1@'`
+ kern_rev3=`uname -r | sed -e 's@^[^.]*\.[^.]*\.\([^.][0-9]*\).*@\1@'`
+
+ dvb_major=250
+
+ if [ $kern_rev1 -gt 2 ] || ([ $kern_rev1 -eq 2 ] && [ $kern_rev2 -gt 6 ]) \
+ || ([ $kern_rev1 -eq 2 ] && [ $kern_rev2 -eq 6 ] && [ $kern_rev3 -ge 8 ])
+ then
+ dvb_major=212
+ fi
+
+ mkdir -p dvb
+ for i in 0 1 2 3
+ do
+ mkdir -p dvb/adapter$i
+ makedev dvb/adapter$i/video0 c $dvb_major `math 64 \* $i + 0` $video
+ makedev dvb/adapter$i/audio0 c $dvb_major `math 64 \* $i + 1` $video
+ makedev dvb/adapter$i/frontend0 c $dvb_major `math 64 \* $i + 3` $video
+ makedev dvb/adapter$i/demux0 c $dvb_major `math 64 \* $i + 4` $video
+ makedev dvb/adapter$i/dvr0 c $dvb_major `math 64 \* $i + 5` $video
+ makedev dvb/adapter$i/ca0 c $dvb_major `math 64 \* $i + 6` $video
+ makedev dvb/adapter$i/net0 c $dvb_major `math 64 \* $i + 7` $video
+ makedev dvb/adapter$i/osd0 c $dvb_major `math 64 \* $i + 8` $video
+ done
+ ;;
usb)
mkdir -p usb
major=180
@@ -1834,30 +2026,67 @@ do
makedev usb/mouse$i c $major `math $i + 16` $mouse
makedev usb/ez$i c $major `math $i + 32` $system
makedev usb/scanner$i c $major `math $i + 48` $scanner
+ makedev usb/hiddev$i c $major `math $i + 96` $system
makedev ttyACM$i c 166 $i $dialout
makedev ttyUSB$i c 188 $i $dialout
done
makedev usb/rio500 c $major 64 $audio
+ makedev usb/usblcd c $major 65 $audio
+ makedev usb/cpad0 c $major 66 $audio
+ ;;
+ bluetooth)
+ major=216
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \
+ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ do
+ makedev rfcomm$i c $major $i $dialout
+ done
+ makedev vhci c 10 250 $dialout
+ for i in 0 1 2 3; do
+ makedev ttyUB$i c 216 $i $dialout
+ makedev ccub$i c 217 $i $dialout
+ done
;;
paride)
- major=45
- for unit in a b c d
+ major=45
+ for unit in a b c d
do
- base=`index abcd $unit`
- base=`math $base \* 16`
- makedev pd$unit b $major $base $disk
- for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- do
- makedev pd$unit$part b $major $(( $base + $part )) $disk
- done
+ base=`index abcd $unit`
+ base=`math $base \* 16`
+ makedev pd$unit b $major $base $disk
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ do
+ makedev pd$unit$part b $major $(( $base + $part )) $disk
+ done
done
for i in 0 1 2 3
do
- makedev pcd$i b 46 $i $cdrom
- makedev pf$i b 47 $i $floppy
+ makedev pcd$i b 46 $i $cdrom
+ makedev pf$i b 47 $i $floppy
done
- ;;
+ ;;
update)
+ devices=
+ if [ ! -f $procfs/devices ]
+ then
+ echo "$0: warning: can't read $procfs/devices" >&2
+ else
+ exec 3<$procfs/devices
+ while read major device extra <&3
+ do
+ device=`echo $device | sed 's#/.*##'`
+ case "$major" in
+ Character|Block|'')
+ ;;
+ *)
+ eval "major_$device=$major"
+ devices="$devices $device"
+ ;;
+ esac
+ done
+ exec 3<&-
+ fi
+
if [ ! "$devices" ]
then
echo "$0: don't appear to have any devices" >&2
@@ -1876,7 +2105,7 @@ do
exec 3<DEVICES
while read device major <&3
do
- eval now=\$major_${device/-/_}
+ eval now=\$major_$device
if [ "$now" = "" ]
then
delete="$delete `cvt $device`"
@@ -1897,7 +2126,7 @@ do
do
if [ "`cvt $device`" ]
then
- eval echo $device \$major_${device/-/_}
+ eval echo $device \$major_$device
fi
done > DEVICES
;;
diff --git a/sbin/functions.sh b/sbin/functions.sh
index 5c5d870..3838e69 100755
--- a/sbin/functions.sh
+++ b/sbin/functions.sh
@@ -36,6 +36,7 @@ RC_ENDCOL="yes"
#
RC_TTY_NUMBER=${RC_TTY_NUMBER:-0}
RC_PARALLEL_STARTUP=${RC_PARALLEL_STARTUP:-no}
+RC_NET_STRICT_CHECKING=${RC_NET_STRICT_CHECKING:-no}
#
# Default values for e-message indentation and dots
diff --git a/sbin/rc b/sbin/rc
index 97b973e..2321579 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -3,6 +3,7 @@
# Distributed under the terms of the GNU General Public License v2
trap ":" INT QUIT TSTP
+
source /sbin/functions.sh
umask 022
@@ -150,6 +151,22 @@ dep_stop() {
[[ ! -L ${svcdir}/softscripts.new/${myservice} ]] || \
return 0
+ # If this is a 'net' service, we do not want to stop it if it was
+ # not in the previous runlevel, and we are not shutting down,
+ # rebooting or going to single runlevel. This is because the user
+ # (or hotplut) might have started it (net.ppp?) ...
+ if net_service "${myservice}" && \
+ [[ ${SOFTLEVEL} != "reboot" && \
+ ${SOFTLEVEL} != "shutdown" && \
+ ${SOFTLEVEL} != "single" ]] ; then
+ if [[ -z ${OLDSOFTLEVEL} ]] || \
+ ! in_runlevel "${myservice}" "${OLDSOFTLEVEL}" ; then
+ # This service is not in the previous runlevel, so
+ # do not stop it ...
+ return 0
+ fi
+ fi
+
# Should not work for 'use'
if [[ -z $(needsme "${myservice}") ]] ; then
# Nothing depends on me
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 4a177cd..0badfd5 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -601,6 +601,50 @@ service_failed() {
[[ -n $1 && -L ${svcdir}/failed/$1 ]]
}
+# bool net_service(service)
+#
+# Returns true if 'service' is a service controlling a network interface
+#
+net_service() {
+ [[ -n $1 && ${1%%.*} == "net" && ${1##*.} != "$1" ]]
+}
+
+# bool is_net_up()
+#
+# Return true if service 'net' is considered up, else false.
+#
+# Notes for RC_NET_STRICT_CHECKING values:
+# none net is up without checking anything - usefull for vservers
+# lo Interface 'lo' is counted and if only it is up, net is up.
+# no Interface 'lo' is not counted, and net is down even with it up,
+# so there have to be at least one other interface up.
+# yes All interfaces must be up.
+is_net_up() {
+ local netcount=0
+
+ case "${RC_NET_STRICT_CHECKING}" in
+ none)
+ return 0
+ ;;
+ lo)
+ netcount="$(ls -1 "${svcdir}"/started/net.* 2> /dev/null | \
+ egrep -c "\/net\..*$")"
+ ;;
+ *)
+ netcount="$(ls -1 "${svcdir}"/started/net.* 2> /dev/null | \
+ grep -v 'net\.lo' | egrep -c "\/net\..*$")"
+ ;;
+ esac
+
+ # Only worry about net.* services if this is the last one running,
+ # or if RC_NET_STRICT_CHECKING is set ...
+ if [[ "${netcount}" -lt 1 || ${RC_NET_STRICT_CHECKING} == "yes" ]] ; then
+ return 1
+ fi
+
+ return 0
+}
+
# bool dependon(service1, service2)
#
# Does service1 depend (NEED or USE) on service2 ?
@@ -625,7 +669,8 @@ valid_i() {
for x in $( i$1 "$2" ) ; do
[[ -e /etc/runlevels/${BOOTLEVEL}/${x} || \
- -e "/etc/runlevels/${mylevel}/${x}" ]] \
+ -e "/etc/runlevels/${mylevel}/${x}" || \
+ ${x} == "net" ]] \
&& echo "${x}"
done
@@ -660,7 +705,18 @@ trace_dependencies() {
if [[ $1 == -* ]] ; then
deptype=${1/-}
- services=( "${myservice}" )
+ if net_service "${myservice}" ; then
+ services=( "net" "${myservice}" )
+ else
+ services=( "${myservice}" )
+ fi
+ fi
+
+ # If its a net service, just replace it with 'net'
+ if [[ -z ${deptype} ]] ; then
+ for (( i=0; i<${#services[@]} ; i++ )) ; do
+ net_service "${services[i]}" && services[i]="net"
+ done
fi
sort_unique() {
@@ -684,6 +740,11 @@ trace_dependencies() {
ndeps=( "${ndeps[@]}" $( valid_iafter "${services[i]}" ) )
fi
+ #If its a net service, just replace it with 'net'
+ for (( j=0; j<${#ndeps[*]}; j++ )) ; do
+ net_service "${ndeps[j]}" && ndeps[j]="net"
+ done
+
deps=( "${deps[@]}" "${ndeps[@]}" )
fi
done
@@ -715,6 +776,13 @@ trace_dependencies() {
deps="${deps} $( valid_iafter ${service} )"
fi
+ if [[ -z ${deptype} ]] ; then
+ # If its a net service, just replace it with 'net'
+ for (( j=0; j<${#deps[@]}; j++ )) ; do
+ net_service "${deps[j]}" && deps[j]="net"
+ done
+ fi
+
for x in ${deps} ; do
after_visit "${x}"
done
@@ -731,6 +799,43 @@ trace_dependencies() {
# If deptype is set, we do not want the name of this service
x=" ${services[@]} "
services=( ${x// ${myservice} / } )
+
+ # If its a net service, do not include "net"
+ if net_service "${myservice}" ; then
+ x=" ${services[@]} "
+ sorted=( ${services// net / } )
+ fi
+ else
+ local netserv y
+
+ # XXX: I dont think RC_NET_STRICT_CHECKING should be considered
+ # here, but you never know ...
+ netserv=$( cd "${svcdir}"/started; ls net.* 2>/dev/null )
+
+ get_netservices() {
+ local runlevel=$1
+
+ if [[ -d /etc/runlevels/${runlevel} ]] ; then
+ cd "/etc/runlevels/${runlevel}"
+ ls net.* 2>/dev/null
+ fi
+ }
+
+ # If no net services are running or we only have net.lo up, then
+ # assume we are in boot runlevel or starting a new runlevel
+ if [[ -z ${netserv} || ${netserv} == "net.lo" ]] ; then
+ local mylevel=${BOOTLEVEL}
+ local startnetserv=$( get_netservices "${mylevel}" )
+
+ [[ -f ${svcdir}/softlevel ]] && mylevel=$( < "${svcdir}/softlevel" )
+ [[ ${BOOTLEVEL} != "${mylevel}" ]] && \
+ startnetserv="${startnetserv} $( get_netservices "${mylevel}" )"
+ [[ -n ${startnetserv} ]] && netserv=${startnetserv}
+ fi
+
+ # Replace 'net' with the actual net services
+ x=" ${services[@]} "
+ services=( ${x// net / ${netserv} } )
fi
echo "${services[@]}"
@@ -743,13 +848,19 @@ trace_dependencies() {
#
query_before() {
local x list
+ local netservice="no"
[[ -z $1 || -z $2 ]] && return 1
list=$( trace_dependencies "$1" )
+ net_service "$2" && netservice="yes"
+
for x in ${list} ; do
[[ ${x} == "$2" ]] && return 0
+
+ # Also match "net" if this is a network service ...
+ [[ ${netservice} == "yes" && ${x} == "net" ]] && return 0
done
return 1
diff --git a/sbin/rc-update b/sbin/rc-update
index 90c0b7a..a4150f8 100755
--- a/sbin/rc-update
+++ b/sbin/rc-update
@@ -11,16 +11,16 @@ usage: rc-update -a|add script runlevel2 [runlevel2 ...]
rc-update -s|show [runlevel1 ...]
examples:
- # rc-update add sysklogd default
- Adds the sysklogd script (in /etc/init.d) to the "default" runlevel.
+ # rc-update add net.eth0 default
+ Adds the net.eth0 script (in /etc/init.d) to the "default" runlevel.
# rc-update del sysklogd
Deletes the sysklogd script from all runlevels. The original script
is not deleted, just any symlinks to the script in /etc/runlevels/*.
- # rc-update del sysklogd default wumpus
- Delete the sysklogd script from the default and wumpus runlevels.
- All other runlevels are unaffected. Again, the sysklogd script
+ # rc-update del net.eth2 default wumpus
+ Delete the net.eth2 script from the default and wumpus runlevels.
+ All other runlevels are unaffected. Again, the net.eth2 script
residing in /etc/init.d is not deleted, just any symlinks in
/etc/runlevels/default and /etc/runlevels/wumpus.
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 79820f3..aec6799 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -30,14 +30,26 @@ myservice=${myservice##*/}
export SVCNAME=${myservice}
mylevel=$(<"${svcdir}/softlevel")
+# Set $IFACE to the name of the network interface if it is a 'net.*' script
+if [[ ${myservice%%.*} == "net" && ${myservice##*.} != "${myservice}" ]] ; then
+ IFACE=${myservice##*.}
+ NETSERVICE="yes"
+else
+ IFACE=
+ NETSERVICE=
+fi
+
# Source configuration files.
# (1) Source /etc/conf.d/${myservice} to get initscript-specific
# configuration (if it exists).
-# (2) Source /etc/rc.conf to pick up potentially overriding
+# (2) Source /etc/conf.d/net if it is a net.* service
+# (3) Source /etc/rc.conf to pick up potentially overriding
# configuration, if the system administrator chose to put it
# there (if it exists).
[[ -e $(add_suffix /etc/conf.d/${myservice}) ]] && source "$(add_suffix /etc/conf.d/${myservice})"
+[[ -e $(add_suffix /etc/conf.d/net) ]] && \
+[[ ${NETSERVICE} == "yes" ]] && source "$(add_suffix /etc/conf.d/net)"
[[ -e $(add_suffix /etc/rc.conf) ]] && source "$(add_suffix /etc/rc.conf)"
usage() {
@@ -102,7 +114,21 @@ svc_stop() {
fi
if [[ ${svcpause} != "yes" ]] ; then
- mydeps=${myservice}
+ if [[ ${NETSERVICE} == "yes" ]] ; then
+ # A net.* service
+ if in_runlevel "${myservice}" "${BOOTLEVEL}" || \
+ in_runlevel "${myservice}" "${mylevel}" ; then
+ # Only worry about net.* services if this is the last one running,
+ # or if RC_NET_STRICT_CHECKING is set ...
+ if ! is_net_up ; then
+ mydeps="net"
+ fi
+ fi
+
+ mydeps="${mydeps} ${myservice}"
+ else
+ mydeps=${myservice}
+ fi
fi
# Save the IN_BACKGROUND var as we need to clear it for stopping depends
@@ -266,18 +292,53 @@ svc_start() {
# Start dependencies, if any
for x in ${startupservices} ; do
- if service_stopped "${x}" ; then
- start_service "${x}"
+ if [[ ${x} == "net" ]] && [[ ${NETSERVICE} != "yes" ]] && ! is_net_up ; then
+ local netservices="$(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
+ $(dolisting "/etc/runlevels/${mylevel}/net.*")"
+
+ for y in ${netservices} ; do
+ mynetservice=${y##*/}
+ if service_stopped "${mynetservice}" ; then
+ start_service "${mynetservice}"
+ fi
+ done
+ elif [[ ${x} != "net" ]] ; then
+ if service_stopped "${x}" ; then
+ start_service "${x}"
+ fi
fi
done
# wait for dependencies to finish
for x in ${startupservices} ; do
- wait_service "${x}"
- if ! service_started "${x}" ; then
- # A 'need' dependacy is critical for startup
- if ineed -t "${myservice}" "${x}" >/dev/null ; then
- startfail="yes"
+ if [ "${x}" = "net" -a "${NETSERVICE}" != "yes" ] ; then
+ local netservices="$(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
+ $(dolisting "/etc/runlevels/${mylevel}/net.*")"
+
+ for y in ${netservices} ; do
+ mynetservice="${y##*/}"
+
+ wait_service "${mynetservice}"
+
+ if ! service_started "${mynetservice}" ; then
+ # A 'need' dependency is critical for startup
+ if ineed -t "${myservice}" "${x}" >/dev/null ; then
+ # Only worry about a net.* service if we do not have one
+ # up and running already, or if RC_NET_STRICT_CHECKING
+ # is set ....
+ if ! is_net_up ; then
+ startfail="yes"
+ fi
+ fi
+ fi
+ done
+ elif [ "${x}" != "net" ] ; then
+ wait_service "${x}"
+ if ! service_started "${x}" ; then
+ # A 'need' dependacy is critical for startup
+ if ineed -t "${myservice}" "${x}" >/dev/null ; then
+ startfail="yes"
+ fi
fi
fi
done