b1e50be2c6
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
85 lines
1.3 KiB
Bash
85 lines
1.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: ppp
|
|
# REQUIRE: netif isdnd
|
|
# KEYWORD: nojail
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="ppp"
|
|
rcvar=`set_rcvar`
|
|
command="/usr/sbin/${name}"
|
|
start_cmd="ppp_start"
|
|
start_postcmd="ppp_poststart"
|
|
|
|
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"
|
|
fi
|
|
|
|
rc_flags="-quiet -${_ppp_mode}"
|
|
|
|
# Switch on NAT mode?
|
|
#
|
|
case ${_ppp_nat} in
|
|
[Yy][Ee][Ss])
|
|
rc_flags="$rc_flags -nat"
|
|
;;
|
|
esac
|
|
|
|
# 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()
|
|
{
|
|
# 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"
|