File: decnet.sh

package info (click to toggle)
dnprogs 2.18-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,896 kB
  • ctags: 3,051
  • sloc: ansic: 18,586; cpp: 9,436; makefile: 669; sh: 502; awk: 13
file content (144 lines) | stat: -rwxr-xr-x 3,424 bytes parent folder | download
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
#
# decnet.sh
#
# Starts/Stops DECnet processes
#
# This script should go in /etc/init.d      (Debian)
#                          /etc/rc.d/init.d (RedHat)
#                          /sbin/init.d     (SuSE)
#
# and you should link to it from the relevant runlevel startup directory
# eg: (Debian)
#      update-rc.d start 39 S .  stop 11 1 .
#
#     (RedHat)
#      ln -s /etc/rc.d/init.d/decnet /etc/rc.d/rc3.d/S09decnet
#
#     (SuSE)
#      ln -s /sbin/init.d/decnet.sh /sbin/init.d/rc2.d/S05decnet
#
#     (Caldera)
#      ln -s /etc/rc.d/init.d/decnet /etc/rc.d/rc5.d/S01decnet
#
# This script MUST be run before TCP/IP is started unless you have a DEC
# TULIP based ethernet card AND are running Linux 2.2
#
# -----------------------------------------------------------------------------
#
# Daemons to start. You may remove the ones you don't want
#
prefix=/usr/local
daemons="dnetd phoned"

#
# Interfaces to set the MAC address of. If empty all available
# ethernet interfaces will have their MAC address set the the DECnet
# address. If you do not want to do that (or don't want to do it here)
# then remove the -hw switch from the command.
#
# If running on Caldera OpenLinux you may need to add the -f switch to
# startnet to force it to change the MAC address because that 
# distribution's startup scripts UP all the interfaces before calling any
# other scripts :-(
#
interfaces=""

startnet="$prefix/sbin/startnet -hw $interfaces"

#
# See which distribution we are using and customise the start/stop 
# commands and the console display.
#
if [ -d /var/lib/dpkg ]
then
  # Debian
  startcmd="start-stop-daemon --start --quiet --exec"
  stopcmd="start-stop-daemon --stop --quiet --exec"
  startecho="\$i"
  startendecho="."
  stopendecho="done."
elif [ -d /var/lib/YaST ]
then
  # SuSE
  . /etc/rc.config
  startcmd=""
  stopcmd="killproc -TERM"
  startendecho=""
  stopendecho="done."
else
  # Assume RedHat
  . /etc/rc.d/init.d/functions
  startcmd="daemon"
  stopcmd="killproc"
  startendecho=""
  stopendecho="done."
fi

case $1 in
   start)
     if [ ! -f /etc/decnet.conf ]
     then
       echo "DECnet not started as it is not configured."
       exit 1
     fi

     # If there is no DECnet in the kernel then try to load it.
     if [ ! -f /proc/net/decnet ]
     then
       modprobe decnet
       if [ ! -f /proc/net/decnet ]
       then
         echo "DECnet not started as it is not in the kernel."
	 exit 1
       fi
     fi

     echo -n "Starting DECnet: " 

     # Run startnet only if we need to
     EXEC=`cat /proc/net/decnet | sed -n '2s/ *\([0-9]\.[0-9]\).*[0-9]\.[0-9]/\1/p'`
     if [ -z "$EXEC" -o "$EXEC" = "0.0" ]
     then
       $startnet
       if [ $? != 0 ]
       then
         echo error starting socket layer.
         exit 1
       fi
     fi

     for i in $daemons
     do
       $startcmd $prefix/sbin/$i
       echo -n " `eval echo $startecho`"
     done
     echo "$startendecho"
     ;;

   stop)
     echo -n "Stopping DECnet... "
     for i in $daemons
     do
       $stopcmd $prefix/sbin/$i
     done
     echo "$stopendecho"
     ;;

   restart|reload|force-reload)
     echo -n "Restarting DECnet: "
     for i in $daemons
     do
       $stopcmd $prefix/sbin/$i
       $startcmd $prefix/sbin/$i
       echo -n "$startecho"
     done
     echo "$stopendecho"
     ;;

   *)
     echo "Usage $0 {start|stop|restart|force-reload}"
     ;;
esac

exit 0