blob: 75531640b7e354823bea14f5692b86e841c9e233 (
plain)
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
145
146
147
|
#!/bin/sh
########################################################################
# Begin network
#
# Description : Network Control Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# Nathan Coulson - nathan@linuxfromscratch.org
# Kevin P. Fleming - kpfleming@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Changes for NuTyX : piernov - piernov@piernov.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: $network
# Required-Start: $local_fs swap localnet
# Should-Start: $syslog
# Required-Stop: $local_fs swap localnet
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts and configures network interfaces.
# Description: Starts and configures network interfaces.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
# Network configuration
. /etc/sysconfig/network
NM_PIDFILE=/var/run/NetworkManager.pid
WICD_PIDFILE=
TIME=$NETWORKDELAY
case "${1}" in
start)
if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then
log_info_msg "Starting NetworkManager daemon..."
start_daemon /usr/sbin/NetworkManager --pid-file $NM_PIDFILE
evaluate_retval
if [ "${NETWORKWAIT}" == "yes" ]; then
[ -z "${LINKDELAY}" ] && LINKDELAY=10
log_info_msg "Waiting for network..."
nm-online -q --timeout=$LINKDELAY || nm-online -q -x --timeout=30
evaluate_retval
[ -n "${NETWORKDELAY}" ] && /bin/sleep ${NETWORKDELAY}
fi
elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then
log_info_msg "Starting the wicd Daemon..."
start_daemon /usr/share/wicd/daemon/wicd-daemon.py
evaluate_retval
if grep -v ^# /etc/fstab | grep _netdev > /dev/null; then
while ! grep "nameserver" /etc/resolv.conf ;
do
if [ $TIME -gt 0 ]; then
sleep 1
echo -n .
let TIME=$TIME-1
if [ $TIME -lt 1 ]; then
log_failure_msg "Time out"
exit 1
fi
fi
done
log_success_msg "Network successfully configured..."
fi
else
# Start all network interfaces
for file in /etc/sysconfig/ifconfig.*
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]
then
continue
fi
/sbin/ifup ${interface}
done
fi
;;
stop)
if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then
log_info_msg "Stopping NetworkManager daemon..."
killproc -p $NM_PIDFILE /usr/sbin/NetworkManager
evaluate_retval
elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then
log_info_msg "Stopping the wicd Daemon..."
/usr/share/wicd/daemon/wicd-daemon.py --kill
evaluate_retval
else
# Reverse list
net_files=""
for file in /etc/sysconfig/ifconfig.*
do
net_files="${file} ${net_files}"
done
# Stop all network interfaces
for file in ${net_files}
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]
then
continue
fi
/sbin/ifdown ${interface}
done
fi
;;
status)
if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then
statusproc -p $NM_PIDFILE NetworkManager
elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then
statusproc -p /var/run/wicd/wicd.pid /usr/share/wicd/daemon/wicd-daemon.py
fi
;;
restart)
${0} stop
sleep 3
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart|status}"
exit 1
;;
esac
exit 0
# End network
|