#!/bin/sh # # $FreeBSD: src/etc/rc.d/ppp-user,v 1.4 2003/04/18 17:55:05 mtm Exp $ # # PROVIDE: ppp-user # REQUIRE: netif . /etc/rc.subr name="ppp" rcvar="ppp_enable" start_cmd="ppp_start" stop_cmd="ppp_stop" ppp_start() { local _punct_c _punct _ppp_unit _profile=${ppp_profile} _punct=". - / +" for _punct_c in $_punct; do _profile=`ltr ${_profile} ${_punct_c} '_'` done # Establish ppp mode. # if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ -a "${ppp_mode}" != "dedicated" \ -a "${ppp_mode}" != "background" ]; then ppp_mode="auto" fi ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}" # Switch on NAT mode? # case ${ppp_nat} in [Yy][Ee][Ss]) ppp_command="${ppp_command} -nat" ;; esac # Check whether we are asked to use a specific unit # eval _ppp_unit=\$ppp_${_profile}_unit if [ -n "${_ppp_unit}" ]; then ppp_command="${ppp_command} -unit${_ppp_unit}" fi ppp_command="${ppp_command} ${ppp_profile}" echo "Starting ppp as \"${ppp_user}\"" su -m ${ppp_user} -c "exec ${ppp_command}" } ppp_stop() { pids=`check_process /usr/sbin/ppp` if [ -n "${pids}" ]; then for pid in ${pids}; do kill -TERM ${pid} done wait_for_pids ${pids} fi } load_rc_config $name run_rc_command "$1"