diff options
author | emax <emax@FreeBSD.org> | 2007-10-12 16:35:36 +0000 |
---|---|---|
committer | emax <emax@FreeBSD.org> | 2007-10-12 16:35:36 +0000 |
commit | 42544287c5892ecdc0eaf760d4e1921ea72d031a (patch) | |
tree | c0b98271aa3206c7ab5ebdd95f526c5e2c740153 /etc/rc.d/ppp | |
parent | 4f35ee7413502cf02d63d8cb4b1c60b1682f1700 (diff) | |
download | FreeBSD-src-42544287c5892ecdc0eaf760d4e1921ea72d031a.zip FreeBSD-src-42544287c5892ecdc0eaf760d4e1921ea72d031a.tar.gz |
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
Diffstat (limited to 'etc/rc.d/ppp')
-rw-r--r-- | etc/rc.d/ppp | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/etc/rc.d/ppp b/etc/rc.d/ppp index d0c6dc2..f9ff885 100644 --- a/etc/rc.d/ppp +++ b/etc/rc.d/ppp @@ -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() { + local _ppp_profile _ppp_mode _ppp_nat + + _ppp_profile=$1 + + # Check for ppp profile mode override. + # + eval _ppp_mode=\$ppp_${_ppp_profile}_mode + if [ -z "$_ppp_mode" ]; then + _ppp_mode=$ppp_mode + fi + + # 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" + 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}" + 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() |