iwm: Fix S:N reporting in ifconfig(8)
[dragonfly.git] / etc / rc.d / ppp
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/rc.d/ppp-user,v 1.4 2003/04/18 17:55:05 mtm Exp $
4 #
5
6 # PROVIDE: ppp
7 # REQUIRE: netif
8
9 . /etc/rc.subr
10
11 name="ppp"
12 rcvar="ppp_enable"
13 start_cmd="ppp_start"
14 stop_cmd="ppp_stop"
15
16 ppp_start()
17 {
18         local _punct_c _punct _ppp_unit
19         _profile=${ppp_profile}
20
21         _punct=". - / +"
22         for _punct_c in $_punct; do
23                 _profile=`ltr ${_profile} ${_punct_c} '_'`
24         done
25
26         # Establish ppp mode.
27         #
28         if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
29                 -a "${ppp_mode}" != "dedicated" \
30                 -a "${ppp_mode}" != "background" ]; then
31                 ppp_mode="auto"
32         fi
33
34         ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}"
35
36         # Switch on NAT mode?
37         #
38         case ${ppp_nat} in
39         [Yy][Ee][Ss])
40                 ppp_command="${ppp_command} -nat"
41                 ;;
42         esac
43
44         # Check whether we are asked to use a specific unit
45         #
46         eval _ppp_unit=\$ppp_${_profile}_unit
47         if [ -n "${_ppp_unit}" ]; then
48                 ppp_command="${ppp_command} -unit${_ppp_unit}"
49         fi
50
51         ppp_command="${ppp_command} ${ppp_profile}"
52
53         echo "Starting ppp as \"${ppp_user}\""
54         su -m ${ppp_user} -c "exec ${ppp_command}"
55 }
56
57 ppp_stop()
58 {
59         pids=`check_process /usr/sbin/ppp`
60         if [ -n "${pids}" ]; then
61                 for pid in ${pids}; do
62                         kill -TERM ${pid}
63                 done
64                 wait_for_pids ${pids}
65         fi
66 }
67
68 load_rc_config $name
69 run_rc_command "$1"