Teach /etc/rc.d/ppp to start multiple instances of ppp.

ppp_profile variable can now contain multiple profiles.
Overrides for ppp mode and nat can go into ppp_$profile_mode
and ppp_$profile_nat variables respectively. If those are
not specified, defaults from ppp_mode and ppp_nat are used.

Submitted by:	Yuri Kurenkov < y dot kurenkov at init dot ru >
Reviewed by:	mtm
MFC after:	1 week
This commit is contained in:
Maksim Yevmenkin 2007-10-12 16:35:36 +00:00
parent de32d3c5ea
commit b1e50be2c6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=172586
2 changed files with 50 additions and 10 deletions

View File

@ -205,6 +205,12 @@ ppp_nat="YES" # Use PPP's internal network address translation or NO.
ppp_profile="papchap" # Which profile to use from /etc/ppp/ppp.conf.
ppp_user="root" # Which user to run ppp as
# Start multiple instances of ppp at boot time
#ppp_profile="profile1 profile2 profile3" # Which profiles to use
#ppp_profile1_mode="ddial" # Override ppp mode for profile1
#ppp_profile2_nat="NO" # Override nat mode for profile2
# profile3 uses default ppp_mode and ppp_nat
### Network daemon (miscellaneous) ###
hostapd_enable="NO" # Run hostap daemon.
syslogd_enable="YES" # Run syslog daemon (or NO).

View File

@ -12,30 +12,64 @@
name="ppp"
rcvar=`set_rcvar`
command="/usr/sbin/${name}"
start_precmd="ppp_prestart"
start_cmd="ppp_start"
start_postcmd="ppp_poststart"
ppp_prestart()
ppp_start_profile()
{
# Establish ppp mode.
local _ppp_profile _ppp_mode _ppp_nat
_ppp_profile=$1
# Check for ppp profile mode override.
#
if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
-a "${ppp_mode}" != "dedicated" \
-a "${ppp_mode}" != "background" ]; then
ppp_mode="auto"
eval _ppp_mode=\$ppp_${_ppp_profile}_mode
if [ -z "$_ppp_mode" ]; then
_ppp_mode=$ppp_mode
fi
rc_flags="$rc_flags -quiet -${ppp_mode}"
# Check for ppp profile nat override.
#
eval _ppp_nat=\$ppp_${_ppp_profile}_nat
if [ -z "$_ppp_nat" ]; then
_ppp_nat=$ppp_nat
fi
# Establish ppp mode.
#
if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \
-a "${_ppp_mode}" != "dedicated" \
-a "${_ppp_mode}" != "background" ]; then
_ppp_mode="auto"
fi
rc_flags="-quiet -${_ppp_mode}"
# Switch on NAT mode?
#
case ${ppp_nat} in
case ${_ppp_nat} in
[Yy][Ee][Ss])
rc_flags="$rc_flags -nat"
;;
esac
rc_flags="$rc_flags ${ppp_profile}"
# Run!
#
su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}"
}
ppp_start()
{
local _p
echo -n "Starting PPP profile:"
for _p in $ppp_profile; do
echo -n " $_p"
ppp_start_profile $_p
done
echo "."
}
ppp_poststart()