11315edc4b7bfe648c7add8edc6b2745ef3c8f31
[openwrt/svn-archive/archive.git] / net / pure-ftpd / files / pure-ftpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3 START=50
4
5 SSD=start-stop-daemon
6 PIDF=/var/run/pure-ftpd.pid
7 PROG=/usr/sbin/pure-ftpd
8
9 append_bool() {
10 local section="$1"
11 local option="$2"
12 local value="$3"
13 local _val
14 config_get_bool _val "$section" "$option" '0'
15 [ "$_val" -gt 0 ] && append args "$3"
16 }
17
18 append_string() {
19 local section="$1"
20 local option="$2"
21 local value="$3"
22 local _val
23 config_get _val "$section" "$option"
24 [ -n "$_val" ] && append args "$3 $_val"
25 }
26
27 start_service() {
28 local section="$1"
29 args=""
30
31 append_string "$section" port "-S"
32 append_bool "$section" noanonymous "-E"
33 append_bool "$section" chrooteveryone "-A"
34 append_string "$section" maxclientsperip "-c"
35 append_string "$section" maxclientsnumber "-C"
36 append_string "$section" peruserlimits "-y"
37 append_string "$section" umask "-U"
38 append_string "$section" authentication "-l"
39 config_get_bool "enabled" "$section" "enabled" '1'
40 [ "$enabled" -gt 0 ] && $SSD -S -p $PIDF -q -x $PROG -- -g $PIDF -B $args
41 }
42
43 stop_service() {
44 killall pure-ftpd 2>&1 > /dev/null
45
46 # FIXME: Fix Busybox start-stop-daemon to work with multiple PIDs
47 # $SSD -K -p $PIDF -q
48 }
49
50 start() {
51 config_load "pure-ftpd"
52 config_foreach start_service "pure-ftpd"
53 }
54
55 stop() {
56 config_load "pure-ftpd"
57 config_foreach stop_service "pure-ftpd"
58 }