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