2002-06-13 18:14:37 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
#
|
|
|
|
|
|
2005-10-28 12:07:52 -04:00
|
|
|
# PROVIDE: ppp
|
2008-05-26 06:40:09 -04:00
|
|
|
# REQUIRE: netif
|
2004-10-07 09:55:26 -04:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 18:14:37 -04:00
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
|
|
name="ppp"
|
2016-04-23 12:10:54 -04:00
|
|
|
desc="Point to Point Protocol"
|
2012-01-13 21:18:41 -05:00
|
|
|
rcvar="ppp_enable"
|
2005-10-28 12:10:56 -04:00
|
|
|
command="/usr/sbin/${name}"
|
2007-10-12 12:35:36 -04:00
|
|
|
start_cmd="ppp_start"
|
2007-10-18 13:10:40 -04:00
|
|
|
stop_cmd="ppp_stop"
|
2007-03-31 05:03:38 -04:00
|
|
|
start_postcmd="ppp_poststart"
|
2002-06-13 18:14:37 -04:00
|
|
|
|
2007-10-12 12:35:36 -04:00
|
|
|
ppp_start_profile()
|
2002-06-13 18:14:37 -04:00
|
|
|
{
|
2008-03-28 03:57:52 -04:00
|
|
|
local _ppp_profile _ppp_mode _ppp_nat _ppp_unit
|
2008-04-09 21:32:49 -04:00
|
|
|
local _ppp_profile_cleaned _punct _punct_c
|
2007-10-12 12:35:36 -04:00
|
|
|
|
|
|
|
|
_ppp_profile=$1
|
2008-03-26 17:54:48 -04:00
|
|
|
_ppp_profile_cleaned=$1
|
|
|
|
|
_punct=". - / +"
|
|
|
|
|
for _punct_c in $_punct; do
|
|
|
|
|
_ppp_profile_cleaned=`ltr ${_ppp_profile_cleaned} ${_punct_c} '_'`
|
|
|
|
|
done
|
2007-10-12 12:35:36 -04:00
|
|
|
|
|
|
|
|
# Check for ppp profile mode override.
|
|
|
|
|
#
|
2008-03-26 17:54:48 -04:00
|
|
|
eval _ppp_mode=\$ppp_${_ppp_profile_cleaned}_mode
|
2007-10-12 12:35:36 -04:00
|
|
|
if [ -z "$_ppp_mode" ]; then
|
|
|
|
|
_ppp_mode=$ppp_mode
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check for ppp profile nat override.
|
|
|
|
|
#
|
2008-03-26 17:54:48 -04:00
|
|
|
eval _ppp_nat=\$ppp_${_ppp_profile_cleaned}_nat
|
2007-10-12 12:35:36 -04:00
|
|
|
if [ -z "$_ppp_nat" ]; then
|
|
|
|
|
_ppp_nat=$ppp_nat
|
|
|
|
|
fi
|
|
|
|
|
|
2002-06-13 18:14:37 -04:00
|
|
|
# Establish ppp mode.
|
|
|
|
|
#
|
2007-10-12 12:35:36 -04:00
|
|
|
if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \
|
|
|
|
|
-a "${_ppp_mode}" != "dedicated" \
|
|
|
|
|
-a "${_ppp_mode}" != "background" ]; then
|
|
|
|
|
_ppp_mode="auto"
|
2002-06-13 18:14:37 -04:00
|
|
|
fi
|
|
|
|
|
|
2007-10-12 12:35:36 -04:00
|
|
|
rc_flags="-quiet -${_ppp_mode}"
|
2002-06-13 18:14:37 -04:00
|
|
|
|
|
|
|
|
# Switch on NAT mode?
|
|
|
|
|
#
|
2007-10-12 12:35:36 -04:00
|
|
|
case ${_ppp_nat} in
|
2002-06-13 18:14:37 -04:00
|
|
|
[Yy][Ee][Ss])
|
2004-12-15 07:39:28 -05:00
|
|
|
rc_flags="$rc_flags -nat"
|
2002-06-13 18:14:37 -04:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2008-03-28 03:57:52 -04:00
|
|
|
# Check for hard wired unit
|
|
|
|
|
eval _ppp_unit=\$ppp_${_ppp_profile_cleaned}_unit
|
2008-04-06 16:39:33 -04:00
|
|
|
if [ -n "${_ppp_unit}" ]; then
|
2008-03-28 03:57:52 -04:00
|
|
|
_ppp_unit="-unit${_ppp_unit}"
|
|
|
|
|
fi
|
|
|
|
|
rc_flags="$rc_flags $_ppp_unit"
|
|
|
|
|
|
2007-10-12 12:35:36 -04:00
|
|
|
# Run!
|
|
|
|
|
#
|
|
|
|
|
su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ppp_start()
|
|
|
|
|
{
|
2007-10-18 13:10:40 -04:00
|
|
|
local _ppp_profile _p
|
|
|
|
|
|
|
|
|
|
_ppp_profile=$*
|
|
|
|
|
if [ -z "${_ppp_profile}" ]; then
|
|
|
|
|
_ppp_profile=$ppp_profile
|
|
|
|
|
fi
|
2007-10-12 12:35:36 -04:00
|
|
|
|
|
|
|
|
echo -n "Starting PPP profile:"
|
|
|
|
|
|
2007-10-18 13:10:40 -04:00
|
|
|
for _p in $_ppp_profile; do
|
2007-10-12 12:35:36 -04:00
|
|
|
echo -n " $_p"
|
|
|
|
|
ppp_start_profile $_p
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "."
|
2004-12-15 07:39:28 -05:00
|
|
|
}
|
2002-06-13 18:14:37 -04:00
|
|
|
|
2007-03-31 05:03:38 -04:00
|
|
|
ppp_poststart()
|
2004-12-15 07:39:28 -05:00
|
|
|
{
|
2006-10-25 20:29:43 -04:00
|
|
|
# Re-Sync ipfilter and pf so they pick up any new network interfaces
|
2002-06-13 18:14:37 -04:00
|
|
|
#
|
2009-09-14 12:52:38 -04:00
|
|
|
if [ -f /etc/rc.d/ipfilter ]; then
|
|
|
|
|
/etc/rc.d/ipfilter quietresync
|
|
|
|
|
fi
|
|
|
|
|
if [ -f /etc/rc.d/pf ]; then
|
|
|
|
|
/etc/rc.d/pf quietresync
|
|
|
|
|
fi
|
2002-06-13 18:14:37 -04:00
|
|
|
}
|
|
|
|
|
|
2007-10-18 13:10:40 -04:00
|
|
|
ppp_stop_profile() {
|
|
|
|
|
local _ppp_profile
|
|
|
|
|
|
|
|
|
|
_ppp_profile=$1
|
|
|
|
|
|
|
|
|
|
/bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \
|
|
|
|
|
echo -n "(not running)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ppp_stop() {
|
|
|
|
|
local _ppp_profile _p
|
|
|
|
|
|
|
|
|
|
_ppp_profile=$*
|
|
|
|
|
if [ -z "${_ppp_profile}" ]; then
|
|
|
|
|
_ppp_profile=$ppp_profile
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo -n "Stopping PPP profile:"
|
|
|
|
|
|
|
|
|
|
for _p in $_ppp_profile; do
|
|
|
|
|
echo -n " $_p"
|
|
|
|
|
ppp_stop_profile $_p
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "."
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-13 18:14:37 -04:00
|
|
|
load_rc_config $name
|
2007-10-18 13:10:40 -04:00
|
|
|
run_rc_command $*
|