multiple instances of ppp
Maksim Yevmenkin
maksim.yevmenkin at gmail.com
Sat Oct 6 13:39:10 PDT 2007
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"
More information about the freebsd-rc
mailing list