]> git.pld-linux.org Git - projects/rc-scripts.git/blob - sysconfig/network-scripts/ifup-ppp
f773ada438c2d26d37bc08483082bf62c093f237
[projects/rc-scripts.git] / sysconfig / network-scripts / ifup-ppp
1 #!/bin/sh
2
3 # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2
4 # Grzegorz Stanislawski <stangrze@open.net.pl>
5 # Features:
6 #  - since persist option is included to pppd it''s no need to do werid loops
7 #    ifup-ppp script. This also makes your logfile grow slower when Your link
8 #    is down.
9 #  - chat-ppp? file with script for chat is now parsed by shell, so You can
10 #    include in it shell variables (for example $PHONE, $USERNAME)
11 #    You can define any variable in ifcfg-ppp? file and use it in chat-ppp?
12 #    You only have to add it's name into DATAFORCHAT variable
13 #    Note, that chat-ppp file is now parsed by shell, so you have to escape
14 #    with "\" all shell special characters like \$;:)(& etc.
15  
16 PATH=/sbin:/usr/sbin:/bin:/usr/bin
17
18 # ifup-post for PPP is handled through /etc/ppp/ip-up
19 if [ "$1" != daemon ] ; then
20   # disconnect stdin, out, err to disassociate from controlling tty
21   # so that no HUPs will get through.
22   $0 daemon $*& </dev/null >/dev/null 2>/dev/null
23   exit 0
24 fi
25 shift
26
27 CONFIG=$1
28 cd /etc/sysconfig/network-scripts
29 . ./network-functions
30 source_config
31 if [ -z "$HOLDOFF" ]; then
32   HOLDOFF=30
33 fi
34 if [ "$2" = "boot" -a "${ONBOOT}" = "no" ]; then
35   exit
36 fi
37 [ -x /usr/sbin/pppd ] || {
38   echo "/usr/sbin/pppd does not exist or is not executable"
39   echo "ifup-ppp for $DEVICE exiting"
40     logger -p daemon.info -t ifup-ppp \
41     "/usr/sbin/pppd does not exist or is not executable for $DEVICE"
42   exit 1
43 }
44 #[ -f /etc/sysconfig/network-scripts/chat-$DEVICE ] || {
45 #  echo "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist"
46 #  echo "ifup-ppp for $DEVICE exiting"
47 #  logger -p daemon.info -t ifup-ppp \
48 #    "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist for $DEVICE"
49 #  exit 1
50 #}
51 opts="lock"
52 if [ "${PERSIST}" = "yes" ]; then
53   opts="$opts persist holdoff $HOLDOFF"
54 fi
55 if [ "${DEMAND}" = "yes" ]; then
56 #opts="$opts demand active-filter $ACTIVEFILTER idle $IDLE"
57 opts="$opts demand "
58 fi
59 if [ "${HARDFLOWCTL}" = yes ] ; then
60   opts="$opts modem crtscts"
61 fi
62 if [ "${ESCAPECHARS}" = yes ] ; then
63   opts="$opts asyncmap 00000000"
64 fi
65 if [ "${DEFROUTE}" = yes ] ; then
66   opts="$opts defaultroute"
67 fi
68 if [ -n "${MRU}" ] ; then
69   opts="$opts mru ${MRU}"
70 fi
71 if [ -n "${MTU}" ] ; then
72   opts="$opts mtu ${MTU}"
73 fi
74 if [ -n "${IPADDR}${REMIP}" ] ; then
75   # if either IP address is set, the following will work.
76   opts="$opts ${IPADDR}:${REMIP}"
77 fi
78 if [ -n "${PAPNAME}" ] ; then
79   opts="$opts name ${PAPNAME}"
80 fi
81 if [ "${DEBUG}" = yes ] ; then
82   opts="$opts debug"
83   chatdbg="-v"
84 fi
85 if [ -n "${REPORTFILE}"  ] ; then
86   chatrpt="-r ${REPORTFILE}"
87 fi
88 #CHATSCRIPT=/etc/sysconfig/network-scripts/chat-$DEVNAMR
89 #[ -f $CHATSCRIPT ] || {
90 #  CHATSCRIPT=/etc/sysconfig/network-scripts/chat-$PARENTDEVNAME
91 #}
92 > /var/run/ppp-$DEVICE.dev
93 (logger -p daemon.info -t ifup-ppp \
94     "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
95 if [ -n "${CHATSCRIPT}"  ] ; then
96   export chatdbg chatrpt CHATSCRIPT
97   export $DATAFORCHAT
98   /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
99     connect 'eval /usr/sbin/chat $chatdbg $chatrpt \
100     `grep -v ^# ${CHATSCRIPT}`' \
101     remotename $DEVICE ipparam $DEVICE \
102     ${PPPOPTIONS} &
103 else
104   /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
105     remotename $DEVICE ipparam $DEVICE \
106     ${PPPOPTIONS} &
107 fi
108  echo "$!" > /var/run/ppp-$DEVICE.pid
109
This page took 0.314743 seconds and 2 git commands to generate.