aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-sl
blob: 2b53b93e1e2dae3da0eedf8f8b0a2b1bd7b0bf96 (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
#!/bin/sh
TEXTDOMAIN=initscripts
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /etc/rc.d/init.d/functions

# ifup-post can't be done for slip :-( Solution: use PPP

# become a daemon in case we have to persist.
if [ "$1" != daemon ] ; then
  # disconnect stdin, out, err to disassociate from controlling tty
  # so that no HUPs will get through.
  $0 daemon $*& </dev/null >/dev/null 2>/dev/null
  exit 0
fi
shift

cd /etc/sysconfig/network-scripts
. network-functions

CONFIG=$1
source_config

if [ "foo$2" = "fooboot" -a ${ONBOOT} = "no" ]
then
  exit
fi

if [ -z "$RETRYTIMEOUT" ]; then
  RETRYTIMEOUT=30
fi

[ -x /usr/sbin/dip ] || {
  gprintf "%s does not exist or is not executable\n" "/usr/sbin/dip"
  gprintf "%s for %s exiting\n" "ifup-sl" "$DEVICE"
  logger -p daemon.info -t ifup-sl \
    "/usr/sbin/dip does not exist or is not executable for $DEVICE"
  exit 1
}

DIPSCRIPT=/etc/sysconfig/network-scripts/dip-$DEVNAME
[ -f $DIPSCRIPT ] || {
  DIPSCRIPT=/etc/sysconfig/network-scripts/dip-$PARENTDEVNAME
}
[ -f $DIPSCRIPT ] || {
  gprintf "%s does not exist\n" "/etc/sysconfig/network-scripts/dip-$DEVICE"
  gprintf "%s for %s exiting\n" "ifup-sl" "$DEVICE"
  logger -p daemon.info -t ifup-sl \
    "/etc/sysconfig/network-scripts/dip-$DEVICE does not exist for $DEVICE"
  exit 1
}

while : ; do
  echo > /var/run/sl-$DEVICE.dev
  (logger -p daemon.info -t ifup-sl \
    "dip started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
  doexec /usr/sbin/dip dip-$DEVICE $DIPSCRIPT
  if [ "$PERSIST" != "yes" -o ! -f /var/run/sl-$DEVICE.dev ] ; then
    exit 0
  fi
  while [ -f /var/run/LCK..$DEVICE && killall -0 dip ] ; do
        sleep 10
  done
  rm -f /var/run/sl-$DEVICE.dev

  sleep $RETRYTIMEOUT || {
    # sleep was killed
    exit 0
  }
done