]> git.pld-linux.org Git - projects/rc-scripts.git/blob - lib/ifup-sl
- provide stdin for the daemons that just must have it,
[projects/rc-scripts.git] / lib / ifup-sl
1 #!/bin/sh
2 #
3 #       $Id$
4 #
5 PATH=/sbin:/usr/sbin:/bin:/usr/bin
6
7 # ifup-post can't be done for slip :-( Solution: use PPP
8
9 . /etc/sysconfig/network
10 . /etc/rc.d/init.d/functions
11 . /lib/rc-scripts/functions.network
12
13 # become a daemon in case we have to persist.
14 if [ "$1" != daemon ] ; then
15         # disconnect stdin, out, err to disassociate from controlling tty
16         # so that no HUPs will get through.
17         $0 daemon $*& </dev/null >/dev/null 2>/dev/null
18         exit 0
19 fi
20 shift
21
22 CONFIG=$1
23 source_config
24
25 if [ "foo$2" = "fooboot" ] && is_no ${ONBOOT}; then
26         exit
27 fi
28
29 # set all major variables
30 setup_ip_param
31
32 if [ -z "$RETRYTIMEOUT" ]; then
33         RETRYTIMEOUT=30
34 fi
35
36 # Try to load slip module
37 if is_module "slip"; then
38         /sbin/modprobe -s slip
39 fi
40
41 # we can use dip or direct slip connection via slattach
42 if is_no "$DIRECT_CONNECT"; then
43         [ -x /usr/sbin/dip ] || {
44                 nls "%s does not exist or is not executable" "/usr/sbin/dip"
45                 nls "%s for %s exiting" "ifup-sl" "$DEVICE"
46                 logger -p daemon.info -t ifup-sl \
47                         "$(nls '%s does not exist or is not executable for %s' "/usr/sbin/dip" "$DEVICE")"
48                 exit 1
49         }
50
51         DIPSCRIPT=/etc/sysconfig/interfaces/data/dip-$DEVNAME
52         [ -f $DIPSCRIPT ] || {
53                 DIPSCRIPT=/etc/sysconfig/interfaces/data/dip-$PARENTDEVNAME
54         }
55         [ -f $DIPSCRIPT ] || {
56                 nls '%s does not exist' "/etc/sysconfig/interfaces/data/dip-$DEVICE"
57                 nls 'ifup-sl - %s exiting' "$DEVICE"
58                 logger -p daemon.info -t ifup-sl \
59                         "$(nls '%s does not exist for %s' "/etc/sysconfig/interfaces/data/dip-$DEVICE" "$DEVICE")"
60                 exit 1
61         }
62
63         while : ; do
64                 echo > /var/run/sl-$DEVICE.dev
65                 (logger -p daemon.info -t ifup-sl \
66                         "$(nls 'dip started for %s on %s at %s' "$DEVICE" "$MODEMPORT" "$LINESPEED")" &)&
67                 doexec /usr/sbin/dip dip-$DEVICE $DIPSCRIPT
68                 if is_no "$PERSIST" || [ ! -f /var/run/sl-$DEVICE.dev ] ; then
69                         exit 0
70                 fi
71                 rm -f /var/run/sl-$DEVICE.dev
72
73                 sleep $RETRYTIMEOUT || {
74                         # sleep was killed
75                         exit 0
76                 }
77         done
78 else
79         # direct connection via slattach
80         [ -z "$MTU" ] && MTU=1500
81         [ -z "$PROTOCOL" ] && PROTOCOL=slip
82
83         [ -x /sbin/slattach ] || {
84                 nls "%s is missing. Can't continue." "/sbin/slattach"
85                 nls "ifup-sl - %s exiting" "$DEVICE"
86                 logger -p daemon.info -t ifup-sl \
87                         "$(nls '%s does not exist or is not executable for %s' "/sbin/slattach" "$DEVICE")"
88                 exit 1
89         }
90
91         echo > /var/run/sl-$DEVICE.dev
92         (logger -p daemon.info -t ifup-sl \
93                 "$(nls 'slattach started for %s on %s at %s' "$DEVICE" "$MODEMPORT" "$LINESPEED")" &)&
94
95         slattach -p $PROTOCOL -s $LINESPEED $MODEMPORT &
96         usleep 1500
97
98         if is_yes "$IPV4_NETWORKING"; then
99                 if [ -n "$IP4ADDR" -a -n "$REMIP" ]; then
100                         # Peer is only for IPv4
101                         ip -4 addr add $IP4ADDR peer $REMIP dev $DEVICE
102                 fi
103         fi
104
105         if is_yes "$IPV6_NETWORKING"; then
106                 if [ -n "$IP6ADDR" ]; then
107                         ip -6 addr add $IP6ADDR dev $DEVICE
108                 fi
109         fi
110
111         ip link set $DEVICE mtu $MTU up
112
113         # IPv4/6 gateways and default routes
114         setup_ip_gw_ro
115
116         /lib/rc-scripts/ifup-post $1
117 fi
This page took 0.039267 seconds and 3 git commands to generate.