]> git.pld-linux.org Git - projects/rc-scripts.git/blame - lib/ifup-sl
- provide stdin for the daemons that just must have it,
[projects/rc-scripts.git] / lib / ifup-sl
CommitLineData
12de71be 1#!/bin/sh
b0443108 2#
ec8b15cb 3# $Id$
b0443108 4#
7742e157
AF
5PATH=/sbin:/usr/sbin:/bin:/usr/bin
6
7# ifup-post can't be done for slip :-( Solution: use PPP
8
de1fc6ce
JR
9. /etc/sysconfig/network
10. /etc/rc.d/init.d/functions
f67ce454 11. /lib/rc-scripts/functions.network
de1fc6ce 12
7742e157
AF
13# become a daemon in case we have to persist.
14if [ "$1" != daemon ] ; then
5e6dfc29
JR
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
7742e157
AF
19fi
20shift
21
12de71be 22CONFIG=$1
7742e157
AF
23source_config
24
dd4a755f 25if [ "foo$2" = "fooboot" ] && is_no ${ONBOOT}; then
5e6dfc29 26 exit
7742e157
AF
27fi
28
de1fc6ce
JR
29# set all major variables
30setup_ip_param
31
7742e157 32if [ -z "$RETRYTIMEOUT" ]; then
5e6dfc29 33 RETRYTIMEOUT=30
7742e157
AF
34fi
35
39465f4f 36# Try to load slip module
de1fc6ce 37if is_module "slip"; then
170103c8 38 /sbin/modprobe -s slip
39465f4f
AM
39fi
40
c24e165d 41# we can use dip or direct slip connection via slattach
dd4a755f 42if is_no "$DIRECT_CONNECT"; then
5e6dfc29
JR
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 }
c24e165d 50
5e6dfc29
JR
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
74a7f2e4 61 }
7742e157 62
5e6dfc29
JR
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
c24e165d 78else
5e6dfc29
JR
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 }
93f97fc9 90
5e6dfc29
JR
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
74a7f2e4 103 fi
74a7f2e4 104
5e6dfc29
JR
105 if is_yes "$IPV6_NETWORKING"; then
106 if [ -n "$IP6ADDR" ]; then
107 ip -6 addr add $IP6ADDR dev $DEVICE
108 fi
109 fi
de1fc6ce 110
5e6dfc29 111 ip link set $DEVICE mtu $MTU up
98626acd 112
5e6dfc29
JR
113 # IPv4/6 gateways and default routes
114 setup_ip_gw_ro
c24e165d 115
f67ce454 116 /lib/rc-scripts/ifup-post $1
c24e165d 117fi
This page took 0.123989 seconds and 4 git commands to generate.