Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Oct 2007 13:14:18 -0700
From:      "Maksim Yevmenkin" <maksim.yevmenkin@gmail.com>
To:        freebsd-rc@freebsd.org
Subject:   multiple instances of ppp
Message-ID:  <bb4a86c70710061314j588ce9a9s6922d2c1e7100e6a@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
hello,

a friend of mine send me the following /etc/rc.c/ppp replacement
script. the idea is to start multiple instances of ppp at boot time
(possibly with different profiles).

i'm not sure if this is ok to commit as it is, so i decided to ask if
there is a better way to handle this.

any thoughts on the subject is very much appreciated.

thanks,
max

#ppp_enable="NO"        # Start user-ppp (or NO).
#ppp_program="/usr/sbin/ppp"    # Path to user-ppp program.
#ppp_mode="auto"        # Choice of "auto", "ddial", "direct" or "dedicated".
#ppp_nat="YES"          # Use PPP's internal network address translation or NO.
#ppp_user="root"        # Which user to run ppp as
#ppp_profile="papchap"  # Which profiles to use from /etc/ppp/ppp.conf,
#                       # in example:
#                       # ppp_profile="papchap profile2 profile3"
# Override default settings  ppp_mode and ppp_nat for profiles
#ppp_papchap_mode="ddial"
#ppp_profile3_mode="dedicated"
#ppp_profile3_nat="NO"
#

# PROVIDE: ppp
# REQUIRE: netif isdnd
# KEYWORD: nojail

. /etc/rc.subr
name="ppp"
rcvar=`set_rcvar`
command="/usr/sbin/${name}"
start_cmd="ppp_prestart"
start_poststart="ppp_poststart"

ppp_prestart()
{
echo -n "Starting PPP profile:"
for profile in ${ppp_profile}
do
       echo -n " ${profile}"
       # Establish ppp mode.
       #
       rc_flags=''
       eval ppp_mode=\$ppp_${profile}_mode
       if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
               -a "${ppp_mode}" != "dedicated" \
               -a "${ppp_mode}" != "background" ]; then
               ppp_mode="auto"
       fi
       rc_flags="$rc_flags -quiet -${ppp_mode}"

       # Switch on NAT mode?
       #
       nat=$ppp_nat
       eval cur_nat=\$ppp_${profile}_nat
       case $cur_nat in
       [Yy][Ee][Ss]|[Nn][Oo])
               nat=${cur_nat}
               ;;
       esac
       case ${nat} in
       [Yy][Ee][Ss])
               rc_flags="$rc_flags -nat"
               ;;
       esac

       # Run !
       #
       su -m $ppp_user -c "$command ${rc_flags} ${profile}"

done
       echo "."
}

ppp_poststart()
{
       # Re-Sync ipfilter and pf so they pick up any new network interfaces
       #
       /etc/rc.d/ipfilter resync
       /etc/rc.d/pf resync
}

load_rc_config $name
run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70710061314j588ce9a9s6922d2c1e7100e6a>