[packages] pure-ftpd: update to 1.0.32 (#9411), thanks realopty, refresh patches
[openwrt/svn-archive/archive.git] / net / pure-ftpd / files / pure-ftpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 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" trustedgid "-a"
32 append_string "$section" syslogfacility "-f"
33 append_string "$section" fortunesfile "-F"
34 append_string "$section" maxidletime "-I"
35 append_string "$section" maxdiskusagepct "-k"
36 append_string "$section" limitrecursion "-L"
37 append_string "$section" anonymouscancreate "-M"
38 append_string "$section" maxload "-m"
39 append_string "$section" quota "-n"
40 append_string "$section" altlog "-O"
41 append_string "$section" passiveportrange "-p"
42 append_string "$section" forcepassiveip "-P"
43 append_string "$section" anonymousratio "-q"
44 append_string "$section" userratio "-Q"
45 append_string "$section" anonymousbandwidth "-t"
46 append_string "$section" userbandwidth "-T"
47 append_string "$section" minuid "-u"
48 append_string "$section" trustedip "-V"
49 append_string "$section" tls "-Y"
50 append_string "$section" tlsciphersuite "-J"
51
52 append_bool "$section" uploadscript "-o"
53 append_bool "$section" natmode "-N"
54 append_bool "$section" autorename "-r"
55 append_bool "$section" nochmod "-R"
56 append_bool "$section" antiwarez "-s"
57 append_bool "$section" allowuserfxp "-w"
58 append_bool "$section" allowanonymousfxp "-W"
59 append_bool "$section" prohibitdotfileswrite "-x"
60 append_bool "$section" prohibitdotfilesread "-X"
61 append_bool "$section" allowdotfiles "-z"
62 append_bool "$section" customerproof "-Z"
63 append_bool "$section" anonymouscantupload "-i"
64 append_bool "$section" createhomedir "-j"
65 append_bool "$section" keepallfiles "-K"
66 append_bool "$section" norename "-G"
67 append_bool "$section" dontresolve "-H"
68 append_bool "$section" verboselog "-d"
69 append_bool "$section" displaydotfiles "-D"
70 append_bool "$section" anonymousonly "-e"
71 append_bool "$section" brokenclientscompatibility "-b"
72 append_bool "$section" notruncate "-0"
73 append_bool "$section" logpid "-1"
74 append_bool "$section" ipv4only "-4"
75 append_bool "$section" ipv6only "-6"
76
77 append_string "$section" bind "-S"
78 append_string "$section" login "-l"
79
80 append_bool "$section" noanonymous "-E"
81 append_bool "$section" chrooteveryone "-A"
82 append_string "$section" maxclientsperip "-c"
83 append_string "$section" maxclientsnumber "-C"
84 append_string "$section" peruserlimits "-y"
85 append_string "$section" umask "-U"
86
87 append_string "$section" port "-S"
88 append_string "$section" authentication "-l"
89
90 config_get_bool "enabled" "$section" "enabled" '1'
91 [ "$enabled" -gt 0 ] && $SSD -S -p $PIDF -q -x $PROG -- -g $PIDF -B $args
92 }
93
94 stop_service() {
95 killall pure-ftpd 2>&1 > /dev/null
96
97 # FIXME: Fix Busybox start-stop-daemon to work with multiple PIDs
98 # $SSD -K -p $PIDF -q
99 }
100
101 start() {
102 config_load "pure-ftpd"
103 config_foreach start_service "pure-ftpd"
104 }
105
106 stop() {
107 config_load "pure-ftpd"
108 config_foreach stop_service "pure-ftpd"
109 }