diff options
author | Chuck Brewer <killian@gentoo.org> | 2003-05-23 04:45:18 +0000 |
---|---|---|
committer | Chuck Brewer <killian@gentoo.org> | 2003-05-23 04:45:18 +0000 |
commit | ce6145302f9a113348552be061a6b52d78774aa9 (patch) | |
tree | 2284626bb8d4ae5d0382ca6713c2880ad644250c /net-dialup | |
parent | Fixing bug 21521. (diff) | |
download | gentoo-2-ce6145302f9a113348552be061a6b52d78774aa9.tar.gz gentoo-2-ce6145302f9a113348552be061a6b52d78774aa9.tar.bz2 gentoo-2-ce6145302f9a113348552be061a6b52d78774aa9.zip |
baselayout takeover
Diffstat (limited to 'net-dialup')
-rw-r--r-- | net-dialup/ppp/files/chat-default | 15 | ||||
-rw-r--r-- | net-dialup/ppp/files/confd.ppp0 | 59 | ||||
-rw-r--r-- | net-dialup/ppp/files/net.ppp0 | 216 |
3 files changed, 290 insertions, 0 deletions
diff --git a/net-dialup/ppp/files/chat-default b/net-dialup/ppp/files/chat-default new file mode 100644 index 000000000000..eeeb5fb91a47 --- /dev/null +++ b/net-dialup/ppp/files/chat-default @@ -0,0 +1,15 @@ +# /etc/ppp/chat-default: +# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/chat-default,v 1.1 2003/05/23 04:45:18 killian Exp $ + +'ABORT' 'BUSY' +'ABORT' 'ERROR' +'ABORT' 'NO ANSWER' +'ABORT' 'NO CARRIER' +'ABORT' 'NO DIALTONE' +'ABORT' 'Invalid Login' +'ABORT' 'Login incorrect' +'' 'ATZ' +'OK' 'ATDT$NUMBER' +'CONNECT' '' +'TIMEOUT' '5' +'~--' '' diff --git a/net-dialup/ppp/files/confd.ppp0 b/net-dialup/ppp/files/confd.ppp0 new file mode 100644 index 000000000000..abdc113a5a64 --- /dev/null +++ b/net-dialup/ppp/files/confd.ppp0 @@ -0,0 +1,59 @@ +# /etc/conf.d/net.ppp0: +# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/confd.ppp0,v 1.1 2003/05/23 04:45:18 killian Exp $ + +# Config file for /etc/init.d/net.ppp0 + + +PEER="MyPeer" # 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/ttyS1" # TTY device modem is connected to +LINESPEED="115200" # Speed pppd should try to connect at +INITSTRING="" # 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? + +# This does not currently work due to a bug in pppd (I think) +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 one + # argument, namely the action that should + # be taken (start|stop). The name of the + # external interface on which the firewall + # should be activated, should be hardcoded + # into the script (you will tipically have + # fw.ppp0, fw.ppp1, etc if you have more than + # one ppp interface). + # + # called: ${FWSCRIPT} [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 FWSCRIPT feature will not work. + + +# Directory where the templates is stored +TEMPLATEDIR=/etc/ppp + diff --git a/net-dialup/ppp/files/net.ppp0 b/net-dialup/ppp/files/net.ppp0 new file mode 100644 index 000000000000..9fdd9b158dac --- /dev/null +++ b/net-dialup/ppp/files/net.ppp0 @@ -0,0 +1,216 @@ +#!/sbin/runscript +# Copyright 1999-2003 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# Author: Martin Schlemmer <azarah@gentoo.org> +# Credits: To all those I got ideas from :) +# +# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/net.ppp0,v 1.1 2003/05/23 04:45:18 killian Exp $ + +# NB: Config is in /etc/conf.d/net.$IFACE + + +# Misc internal variables +CMD_LINE="" +FUNCT="$2" +TEMPLATEDIR="/etc/ppp" + +checkconfig() { + + if [ ! -x "$(which pppd)" -o ! -x "$(which chat)" ] + then + eerror "pppd and chat needs to be installed" + return 1 + fi + + if [ -e "/var/run/ppp-${IFACE}.pid" -o -e "/var/run/${IFACE}.pid" ] && \ + [ "${FUNCT}" = "start" ] + then + eerror "ppp0 is already up" + return 1 + fi +} + +start() { + + checkconfig || return 1 + + setup_cmd_line + setup_cfg_files + + ebegin "Bringing ${IFACE} up" + if [ -x "$(which pppd)" ] + then + + if [ "${DEFROUTE}" = "yes" ] + then + [ -n "$(/sbin/route | egrep 'default')" ] && route del default + fi + # Added hide-password here, can't be too sure... + /usr/sbin/pppd ${CMD_LINE} ${MODEMPORT} ${LINESPEED} \ + ipparam ${IFACE} linkname ${IFACE} call ${PEER} \ + noauth ${PPPOPTIONS} hide-password + fi + eend +} + +stop() { + + checkconfig || return 1 + + ebegin "Bringing ${IFACE} down" + if [ -x "$(which ifconfig)" ] + then + + if [ -z "$(/sbin/ifconfig | egrep "${IFACE}")" ] + then + ewarn "Interface seems to be down already" + # We should return 0 here, else svc_stop() will not remove + # the 'started' symlink ... + return 0 + fi + +# /sbin/ifconfig ${IFACE} down + if [ -e /var/run/ppp-${IFACE}.pid ] + then + kill $(egrep -v "${IFACE}" /var/run/ppp-${IFACE}.pid) + + elif [ -e /var/run/${IFACE}.pid ] + then + kill $(egrep -v "${IFACE}" /var/run/${IFACE}.pid) + fi + 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 "${USERNAME}" ] + then + CMD_LINE="${CMD_LINE} user ${USERNAME} remotename ${PEER}" + fi + + if [ "${ONDEMAND}" = "yes" ] + then + CMD_LINE="${CMD_LINE} demand ktune idle ${IDLETIMEOUT}" + CMD_LINE="${CMD_LINE} 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 600 /etc/ppp/chap-secrets + echo "${USERNAME} ${PEER} \"${PASSWORD}\"" >/etc/ppp/pap-secrets + chmod 600 /etc/ppp/pap-secrets + + # Setup the chat file + if [ -n "${INITSTRING}" ] + then + sed -e "9i\\'OK\' \'${INITSTRING}\'" \ + -e "s:\$NUMBER:${NUMBER}:" \ + ${TEMPLATEDIR}/chat-default \ + >/etc/ppp/chat-${PEER} + else + sed -e "s:\$NUMBER:${NUMBER}:" \ + ${TEMPLATEDIR}/chat-default \ + >/etc/ppp/chat-${PEER} + fi + + # Setup the ip-scripts so long + echo '#!/bin/sh' >/etc/ppp/ip-up + chmod 700 /etc/ppp/ip-up + echo '#!/bin/sh' >/etc/ppp/ip-down + chmod 700 /etc/ppp/ip-down + + # Setup if-up and if-down + if [ -x ${FWSCRIPT} ] + then + echo "${FWSCRIPT} start" >>/etc/ppp/ip-up + echo "${FWSCRIPT} stop" >>/etc/ppp/ip-down + fi + + if [ "${PEERDNS}" = "yes" ] + then + # ip-up: add the server supplied DNS entries to + # /etc/resolv.conf + echo "/bin/cp -f /etc/resolv.conf /etc/resolv.conf.old" \ + >>/etc/ppp/ip-up + echo "/bin/cat /etc/ppp/resolv.conf >> /etc/resolv.conf" \ + >>/etc/ppp/ip-up + # Change perms because it b0rked kppp + echo "chmod 640 /etc/resolv.conf" >>/etc/ppp/ip-up + + # ip-down: restore original /etc/resolv.conf + echo "/bin/mv -f /etc/resolv.conf.old /etc/resolv.conf" \ + >>/etc/ppp/ip-down + echo "chmod 640 /etc/resolv.conf" >>/etc/ppp/ip-down + fi + + echo "[ -f /etc/ppp/ip-up.local ] && . /etc/ppp/ip-up.local" \ + >>/etc/ppp/ip-up + echo "[ -f /etc/ppp/ip-down.local ] && . /etc/ppp/ip-down.local" \ + >>/etc/ppp/ip-down + fi +} + + +# vim:ts=4 |