3 # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2
4 # Grzegorz Stanislawski <stangrze@open.net.pl>
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
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.
16 PATH=/sbin:/usr/sbin:/bin:/usr/bin
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
28 cd /etc/sysconfig/network-scripts
31 if [ -z "$HOLDOFF" ]; then
34 if [ "$2" = "boot" -a "${ONBOOT}" = "no" ]; then
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"
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"
52 if [ "${PERSIST}" = "yes" ]; then
53 opts="$opts persist holdoff $HOLDOFF"
55 if [ "${DEMAND}" = "yes" ]; then
56 #opts="$opts demand active-filter $ACTIVEFILTER idle $IDLE"
59 if [ "${HARDFLOWCTL}" = yes ] ; then
60 opts="$opts modem crtscts"
62 if [ "${ESCAPECHARS}" = yes ] ; then
63 opts="$opts asyncmap 00000000"
65 if [ "${DEFROUTE}" = yes ] ; then
66 opts="$opts defaultroute"
68 if [ -n "${MRU}" ] ; then
69 opts="$opts mru ${MRU}"
71 if [ -n "${MTU}" ] ; then
72 opts="$opts mtu ${MTU}"
74 if [ -n "${IPADDR}${REMIP}" ] ; then
75 # if either IP address is set, the following will work.
76 opts="$opts ${IPADDR}:${REMIP}"
78 if [ -n "${PAPNAME}" ] ; then
79 opts="$opts name ${PAPNAME}"
81 if [ "${DEBUG}" = yes ] ; then
85 if [ -n "${REPORTFILE}" ] ; then
86 chatrpt="-r ${REPORTFILE}"
88 #CHATSCRIPT=/etc/sysconfig/network-scripts/chat-$DEVNAMR
89 #[ -f $CHATSCRIPT ] || {
90 # CHATSCRIPT=/etc/sysconfig/network-scripts/chat-$PARENTDEVNAME
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
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 \
104 /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
105 remotename $DEVICE ipparam $DEVICE \
108 echo "$!" > /var/run/ppp-$DEVICE.pid