]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/initscripts/init.d/tor
tor: Increase number of max. open file descriptors.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / tor
index e27241f5617e93b53d68ce760df57ccf0d9ea034..878080eff3bbe4c220cbfa2fba85f16494a0f2a9 100644 (file)
@@ -9,9 +9,15 @@
 . /etc/sysconfig/rc
 . ${rc_functions}
 
-function setup_firewall() {
-       eval $(/usr/local/bin/readhash /var/ipfire/tor/settings)
+FILEDESCRIPTORS="65535"
+
+eval $(/usr/local/bin/readhash /var/ipfire/tor/settings)
+
+function tor_is_enabled() {
+       [ "${TOR_ENABLED}" = "on" ] || [ "${TOR_RELAY_ENABLED}" = "on" ]
+}
 
+function setup_firewall() {
        # Flush all rules.
        flush_firewall
 
@@ -27,9 +33,16 @@ function flush_firewall() {
 
 case "${1}" in
        start)
+               tor_is_enabled || exit 0
+
                # Setup firewall.
                setup_firewall
 
+               # Increasing open file descriptors.
+               if [ -n "${FILEDESCRIPTORS}" ]; then
+                       ulimit -n "${FILEDESCRIPTORS}"
+               fi
+
                boot_mesg "Starting tor..."
                loadproc /usr/bin/tor \
                        --runasdaemon 1 \