]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/tor
ovpnmain.cgi: Don't fail if files are not existant.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / tor
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/tor
4 #
5 # Description : Anonymizing overlay network for TCP
6 #
7 ########################################################################
8
9 . /etc/sysconfig/rc
10 . ${rc_functions}
11
12 function setup_firewall() {
13 eval $(/usr/local/bin/readhash /var/ipfire/tor/settings)
14
15 # Flush all rules.
16 flush_firewall
17
18 if [ "${TOR_RELAY_ENABLED}" = "on" -a -n "${TOR_RELAY_PORT}" ]; then
19 iptables -A TOR_INPUT -p tcp --dport "${TOR_RELAY_PORT}" -j ACCEPT
20 fi
21 }
22
23 function flush_firewall() {
24 # Flush all rules.
25 iptables -F TOR_INPUT
26 }
27
28 case "${1}" in
29 start)
30 # Setup firewall.
31 setup_firewall
32
33 boot_mesg "Starting tor..."
34 loadproc /usr/bin/tor \
35 --runasdaemon 1 \
36 --defaults-torrc /usr/share/tor/defaults-torrc \
37 -f /etc/tor/torrc \
38 --quiet
39 ;;
40
41 stop)
42 # Flush firewall.
43 flush_firewall
44
45 boot_mesg "Stopping tor..."
46 killproc /usr/bin/tor
47 ;;
48
49 reload)
50 # Setup firewall.
51 setup_firewall
52
53 boot_mesg "Reloading tor..."
54 reloadproc /usr/bin/tor
55 ;;
56
57 restart)
58 ${0} stop
59 sleep 1
60 ${0} start
61 ;;
62
63 reload-or-restart)
64 # Reload the process if it is already running. Otherwise, restart.
65 if pidofproc -s /usr/bin/tor; then
66 $0 reload
67 else
68 $0 restart
69 fi
70 ;;
71
72 status)
73 statusproc /usr/bin/tor
74 ;;
75
76 *)
77 echo "Usage: ${0} {start|stop|reload|restart|reload-or-restart|status}"
78 exit 1
79 ;;
80 esac
81
82 # End $rc_base/init.d/tor