horst: moved to github
[packages.git] / net / pure-ftpd / files / pure-ftpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 OpenWrt.org
3
4 START=50
5
6 # TODO: allow multiple instance to run with different pid-files
7
8 # XXX: pure-ftpd changes it's name to 'pure-ftpd (SERVER) ...'
9 SERVICE_MATCH_EXEC=
10 SERVICE_MATCH_NAME=1
11 SERVICE_USE_PID=1
12
13 append_bool() {
14         local section="$1"
15         local option="$2"
16         local value="$3"
17         local _val
18         config_get_bool _val "$section" "$option" '0'
19         [ "$_val" -gt 0 ] && append args "$3"
20 }
21
22 append_string() {
23         local section="$1"
24         local option="$2"
25         local value="$3"
26         local _val
27         config_get _val "$section" "$option"
28         [ -n "$_val" ] && append args "$3 $_val"
29 }
30
31 start_instance() {
32         local section="$1"
33
34         config_get_bool enabled "$section" 'enabled' '1'
35         [ $enabled -gt 0 ] || return 1
36
37         args=""
38         append_string "$section" trustedgid "-a"
39         append_string "$section" syslogfacility "-f"
40         append_string "$section" fortunesfile "-F"
41         append_string "$section" maxidletime "-I"
42         append_string "$section" maxdiskusagepct "-k"
43         append_string "$section" limitrecursion "-L"
44         append_string "$section" anonymouscancreate "-M"
45         append_string "$section" maxload "-m"
46         append_string "$section" quota "-n"
47         append_string "$section" altlog "-O"
48         append_string "$section" passiveportrange "-p"
49         append_string "$section" forcepassiveip "-P"
50         append_string "$section" anonymousratio "-q"
51         append_string "$section" userratio "-Q"
52         append_string "$section" anonymousbandwidth "-t"
53         append_string "$section" userbandwidth "-T"
54         append_string "$section" minuid "-u"
55         append_string "$section" trustedip "-V"
56         append_string "$section" tls "-Y"
57         append_string "$section" tlsciphersuite "-J"
58
59         append_bool "$section" uploadscript "-o"
60         append_bool "$section" natmode "-N"
61         append_bool "$section" autorename "-r"
62         append_bool "$section" nochmod "-R"
63         append_bool "$section" antiwarez "-s"
64         append_bool "$section" allowuserfxp "-w"
65         append_bool "$section" allowanonymousfxp "-W"
66         append_bool "$section" prohibitdotfileswrite "-x"
67         append_bool "$section" prohibitdotfilesread "-X"
68         append_bool "$section" allowdotfiles "-z"
69         append_bool "$section" customerproof "-Z"
70         append_bool "$section" anonymouscantupload "-i"
71         append_bool "$section" createhomedir "-j"
72         append_bool "$section" keepallfiles "-K"
73         append_bool "$section" norename "-G"
74         append_bool "$section" dontresolve "-H"
75         append_bool "$section" verboselog "-d"
76         append_bool "$section" displaydotfiles "-D"
77         append_bool "$section" anonymousonly "-e"
78         append_bool "$section" brokenclientscompatibility "-b"
79         append_bool "$section" notruncate "-0"
80         append_bool "$section" logpid "-1"
81         append_bool "$section" ipv4only "-4"
82         append_bool "$section" ipv6only "-6"
83
84         append_string "$section" bind "-S"
85         append_string "$section" login "-l"
86
87         append_bool "$section" noanonymous "-E"
88         append_bool "$section" chrooteveryone "-A"
89         append_string "$section" maxclientsperip "-c"
90         append_string "$section" maxclientsnumber "-C"
91         append_string "$section" peruserlimits "-y"
92         append_string "$section" umask "-U"
93
94         append_string "$section" port "-S"
95         append_string "$section" authentication "-l"
96
97         service_start /usr/sbin/pure-ftpd -B $args
98 }
99
100 start() {
101         config_load "pure-ftpd"
102         config_foreach start_instance "pure-ftpd"
103 }
104
105 stop() {
106         service_stop /usr/sbin/pure-ftpd
107 }