4 # Set to "C" locale so we can parse messages from commands
8 CONFIG
=/etc
/ppp
/pptp.conf
12 # Protect created files
16 if [ "$?" != 0 ] ; then
17 echo "*** Error copying $1 to $2"
24 if [ "`id -u`" != 0 ] ; then
25 echo "$ME: You must be root to run this script" >& 2
29 # Prototype config file must exist
30 if [ ! -r "$CONFIG" ] ; then
31 echo "Oh, dear, I don't see the file '$CONFIG' anywhere. Please"
32 echo "re-install the client."
38 echo "Welcome to the cable connection setup."
39 echo "Please enter some information:"
45 echo -n ">>> Enter your user name (default $USER): "
48 if [ "$U" = "" ] ; then
52 # Under Linux, "fix" the default interface if eth1 is not available
53 if test `uname -s` = "Linux" ; then
54 ifconfig
$ETH > /dev
/null
2>&1 || ETH
=eth0
59 echo ">>> Enter the Ethernet interface connected to the Cable modem"
60 echo "For Linux, it will be ethn, where 'n' is a number."
61 echo -n "(default $ETH): "
64 if [ "$E" = "" ] ; then
71 echo ">>> Enter the Server address of your ISP."
72 echo -n "(default $SERVERADDR): "
74 if [ "$S" = "" ] ; then
81 echo "Please enter the IP address of the primary DNS server."
82 echo "If you want the server to automatically provide you the addresses',"
83 echo "enter 'server' (all lower-case) here."
84 echo "If you just press enter, I will assume you know what you are"
85 echo "doing and not modify your DNS setup."
86 echo -n ">>> Enter the DNS information here: "
91 if [ "$DNS1" != "" ] ; then
92 if [ "$DNS1" != "server" ] ; then
93 echo "Please enter the IP address of your ISP's secondary DNS server."
94 echo "If you just press enter, I will assume there is only one DNS server."
95 echo -n ">>> Enter the secondary DNS server address here: "
106 echo -n ">>> Please enter your password: "
109 echo -n ">>> Please re-enter your password: "
113 if [ "$PWD1" = "$PWD2" ] ; then
117 echo -n ">>> Sorry, the passwords do not match. Try again? (y/n)"
120 N|No|NO|Non|n|no|non
)
121 echo "OK, quitting. Bye."
127 echo "** Summary of what you entered **"
129 echo "Ethernet Interface: $E"
132 if [ "$DNS1" != "" ] ; then
133 if [ "$DNS1" = "server" ] ; then
134 echo "DNS addresses: Supplied by ISP's server"
136 echo "Primary DNS: $DNS1"
137 if [ "$DNS2" != "" ] ; then
138 echo "Secondary DNS: $DNS2"
142 echo "DNS: Do not adjust"
146 echo -n '>>> Accept these settings and adjust configuration files (y/n)? '
156 if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then
160 if [ "$ANS" = "y" ] ; then
165 # Adjust configuration files. First to $CONFIG
166 copy
$CONFIG $CONFIG-bak
167 if [ "$DNS1" = "server" ] ; then
174 if [ "$DNS1" = "" ] ; then
180 # Where is pppd likely to put its pid?
181 if [ -d /var
/run
] ; then
188 sed -e "s&^USER=.*&USER='$U'&" \
189 -e "s&^ETH=.*Ð='$E'&" \
190 -e "s&^SERVERADDR=.*&SERVERADDR='$S'&" \
191 -e "s/^DNSTYPE=.*/DNSTYPE=$DNSTYPE/" \
192 -e "s/^DNS1=.*/DNS1=$DNS1/" \
193 -e "s/^DNS2=.*/DNS2=$DNS2/" \
194 -e "s/^PEERDNS=.*/PEERDNS=$PEERDNS/" \
195 < $CONFIG-bak > $CONFIG
197 if [ $?
!= 0 ] ; then
198 echo "** Error modifying $CONFIG"
203 echo "Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets"
204 if [ -r /etc
/ppp
/pap-secrets
] ; then
205 echo " (But first backing it up to /etc/ppp/pap-secrets-bak)"
206 copy
/etc
/ppp
/pap-secrets
/etc
/ppp
/pap-secrets-bak
208 cp /dev
/null
/etc
/ppp
/pap-secrets-bak
210 if [ -r /etc
/ppp
/chap-secrets
] ; then
211 echo " (But first backing it up to /etc/ppp/chap-secrets-bak)"
212 copy
/etc
/ppp
/chap-secrets
/etc
/ppp
/chap-secrets-bak
214 cp /dev
/null
/etc
/ppp
/chap-secrets-bak
217 egrep -v "^$U|^\"$U\"" /etc
/ppp
/pap-secrets-bak
> /etc
/ppp
/pap-secrets
218 echo "\"$U\" * \"$PWD1\" *" >> /etc
/ppp
/pap-secrets
219 egrep -v "^$U|^\"$U\"" /etc
/ppp
/chap-secrets-bak
> /etc
/ppp
/chap-secrets
220 echo "\"$U\" * \"$PWD1\" *" >> /etc
/ppp
/chap-secrets
225 echo "Congratulations, it should be all set up!"
227 echo "Type: '/etc/rc.d/cable start' - to bring up your CABLE link"
228 echo " '/etc/rc.d/cable stop' - to bring it down"
229 echo " '/etc/rc.d/cable status' - to see the link status."