RCNG, shutdown ppp connections nicely when told to.
[dragonfly.git] / etc / rc.d / ppp-user
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/rc.d/ppp-user,v 1.4 2003/04/18 17:55:05 mtm Exp $
4 # $DragonFly: src/etc/rc.d/ppp-user,v 1.3 2004/02/19 21:32:15 dillon Exp $
5 #
6
7 # PROVIDE: ppp-user
8 # REQUIRE: netif isdnd
9 # KEYWORD: DragonFly
10
11 . /etc/rc.subr
12
13 name="ppp"
14 rcvar="ppp_enable"
15 start_cmd="ppp_start"
16 stop_cmd="ppp_stop"
17
18 ppp_start()
19 {
20         # Establish ppp mode.
21         #
22         if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
23                 -a "${ppp_mode}" != "dedicated" \
24                 -a "${ppp_mode}" != "background" ]; then
25                 ppp_mode="auto"
26         fi
27
28         ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}"
29
30         # Switch on NAT mode?
31         #
32         case ${ppp_nat} in
33         [Yy][Ee][Ss])
34                 ppp_command="${ppp_command} -nat"
35                 ;;
36         esac
37
38         ppp_command="${ppp_command} ${ppp_profile}"
39
40         echo "Starting ppp as \"${ppp_user}\""
41         su -m ${ppp_user} -c "exec ${ppp_command}"
42
43         # Re-Sync ipfilter so it picks up any new network interfaces
44         #
45         /etc/rc.d/ipfilter resync
46 }
47
48 ppp_stop()
49 {
50         pids=`check_process /usr/sbin/ppp`
51         if [ -n "${pids}" ]; then
52                 for pid in ${pids}; do
53                         kill -TERM ${pid}
54                 done
55                 wait_for_pids ${pids}
56         fi
57         /etc/rc.d/ipfilter resync
58 }
59
60 load_rc_config $name
61 run_rc_command "$1"