blob: a9e4e85f1fd1e7dd3c4fb1cdb48efff4bbd28ede (
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
#!/sbin/runscript
# Copyright 1999-2000 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Author Martin Schlemmer <azarah@gentoo.org>
# Credits To all those I got ideas from :)
# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/2.4.1-r6/net.ppp0,v 1.3 2001/11/11 20:13:44 azarah Exp $
PEER="isp" # Define peer (aka ISP)
DEBUG="no" # Turn on debugging
PERSIST="no" # Redial after being dropped
ONDEMAND="no" # Only bring the interface up on demand?
MODEMPORT="/dev/ttyS0" # TTY device modem is connected to
LINESPEED="115200" # Speed pppd should try to connect at
INITSTRING="AT&S2=255" # Extra init string for the modem
DEFROUTE="yes" # Must pppd set the default route?
HARDFLOWCTL="yes" # Use hardware flow control?
ESCAPECHARS="yes" # Use escape caracters ?
PPPOPTIONS="" # Extra options for pppd
USERNAME="user" # The PAP/CHAP username
PASSWORD="passwd" # Your password/secret. Ugly I know, but i
# will work on something more secure later
# on. 700 permission on /etc/init.d/net.ppp0
# should be enouth for now.
NUMBER="9180000" # The telephone number of your ISP
REMIP="" # The ip of the remote box if it should be set
NETMASK="" # Netmask
IPADDR="" # Our IP if we have a static one
MRU="768" # Sets the MRU
MTU="768" # Sets the MTU
RETRYTIMEOUT="60" # Retry timeout for when ONDEMAND="yes" or
# PERSIST="yes"
IDLETIMEOUT="600" # Idle timeout for when ONDEMAND="yes"
PEERDNS="no" # Should pppd set the peer dns?
FWSCRIPT="/etc/init.d/firewall" # Optional FW script that pppd should start
# and stop when the link comes up or drop.
# It should be a script that takes two
# argument, namely the name of the external
# interface on which the firewall should be
# activated and start/stop.
#
# called: ${FWSCRIPT} ${DEVICE} [start|stop]
AUTOCFGFILES="yes" # By default this scripts will generate
# /etc/ppp/chat-isp, /etc/ppp/chap-secrets,
# /etc/ppp/pap-secrets and /etc/ppp/peers/isp
# automagically. Set to "no" if you experience
# problems, or need specialized scripts. You
# will have to create these files by hand then.
# Also, the FWSTART/FWSTOP feature will not
# work.
# Do not change .. for determining name of interface
DEVICE="${1##*.}"
CMD_LINE=""
checkconfig() {
if [ ! -x "`which pppd`" ] || [ ! -x "`which chat`" ] ; then
eerror "pppd and chat needs to be installed"
return 1
fi
if [ -e "/var/run/ppp-${DEVICE}.pid" ] && [ "${1}" = "start" ] ; then
eerror "ppp0 is already up"
return 1
fi
if [ ! -e "/var/run/ppp-${DEVICE}.pid" ] && [ "${1}" = "stop" ] ; then
eerror "ppp0 not up"
return 1
fi
}
start() {
checkconfig || return 1
setup_cmd_line
setup_cfg_files
ebegin "Bringing ${DEVICE} up"
if [ -x "`which pppd`" ]; then
if [ "${DEFROUTE}" = "yes" ] ; then
[ "`/sbin/route |grep default`" ] && route del default
fi
/usr/sbin/pppd ${CMD_LINE} ${MODEMPORT} ${LINESPEED} ipparam ${DEVICE} \
linkname ${DEVICE} call ${PEER} noauth ${PPPOPTIONS}
fi
eend
}
stop() {
checkconfig || return 1
ebegin "Bringing ${DEVICE} down"
if [ -x "`which ifconfig`" ]; then
/sbin/ifconfig ${DEVICE} down
fi
eend
}
setup_cmd_line() {
CMD_LINE="lock"
if [ "${DEBUG}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} debug"
fi
if [ "${PERSIST}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} persist holdoff ${RETRYTIMEOUT}"
fi
if [ "${DEFROUTE}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} defaultroute"
fi
if [ "${HARDFLOWCTL}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} modem crtscts"
fi
if [ "${ESCAPECHARS}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} asyncmap 00000000"
fi
if [ "${PEERDNS}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} usepeerdns"
fi
if [ -n "${IPADDR}${REMIP}" ] ; then
CMD_LINE="${CMD_LINE} ${IPADDR}:${REMIP}"
fi
if [ -n "${NETMASK}" ] ; then
CMD_LINE="${CMD_LINE} netmask ${NETMASK}"
fi
if [ -n "${MRU}" ] ; then
CMD_LINE="${CMD_LINE} mru ${MRU}"
fi
if [ -n "${MTU}" ] ; then
CMD_LINE="${CMD_LINE} mtu ${MTU}"
fi
if [ -n "${PAPNAME}" ] ; then
CMD_LINE="${CMD_LINE} user ${USERNAME} remotename ${PEER}"
fi
if [ "${ONDEMAND}" = "yes" ] ; then
CMD_LINE="${CMD_LINE} demand ktune idle ${IDLETIMEOUT} holdoff ${RETRYTIMEOUT}"
fi
}
setup_cfg_files() {
if [ "${AUTOCFGFILES}" = "yes" ] ; then
# Setup the peers file
echo "connect '/usr/sbin/chat -v -f /etc/ppp/chat-${PEER}'" \
>/etc/ppp/peers/${PEER}
# Setup the secrets files
echo "${USERNAME} ${PEER} \"${PASSWORD}\"" >/etc/ppp/chap-secrets
chmod 660 /etc/ppp/chap-secrets
echo "${USERNAME} ${PEER} \"${PASSWORD}\"" >/etc/ppp/pap-secrets
chmod 660 /etc/ppp/pap-secrets
# Setup the chat file
sed -e "9i\\'OK\' \'${INITSTRING}\'" \
-e "s:\$NUMBER:${NUMBER}:" \
/usr/lib/ppp/chat-default \
>/etc/ppp/chat-${PEER}
# Setup if-up and if-down
if [ -x ${FWSCRIPT} ] ; then
echo "${FWSCRIPT} \${6} start" >/etc/ppp/if-up
chmod 770 /etc/ppp/if-up
echo "${FWSCRIPT} \${6} stop" >/etc/ppp/if-down
chmod 770 /etc/ppp/if-down
if [ "${PEERDNS}" = "yes" ] ; then
# if-up: add the server supplied DNS entries to
# /etc/resolv.conf
echo "cp -f /etc/resolv.conf /etc/resolv.conf.old" \
>>/etc/ppp/if-up
echo "cat /etc/ppp/resolv.conf >> /etc/resolv.conf" \
>>/etc/ppp/if-up
# if-down: restore original /etc/resolv.conf
echo "mv -f /etc/resolv.conf.old /etc/resolv.conf" \
>>/etc/ppp/if-down
fi
fi
fi
}
|