]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/tor
tor: Fix path to readhash in initscript.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / tor
CommitLineData
b312967c
MT
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
c60301c0 12function setup_firewall() {
9e4cb00b 13 eval $(/usr/local/bin/readhash /var/ipfire/tor/settings)
c60301c0
MT
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
23function flush_firewall() {
24 # Flush all rules.
25 iptables -F TOR_INPUT
26}
27
b312967c
MT
28case "${1}" in
29 start)
c60301c0
MT
30 # Setup firewall.
31 setup_firewall
32
b312967c
MT
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)
c60301c0
MT
42 # Flush firewall.
43 flush_firewall
44
b312967c
MT
45 boot_mesg "Stopping tor..."
46 killproc /usr/bin/tor
47 ;;
48
49 reload)
c60301c0
MT
50 # Setup firewall.
51 setup_firewall
52
b312967c
MT
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
27cb7805
MT
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
b312967c
MT
72 status)
73 statusproc /usr/bin/tor
74 ;;
75
76 *)
27cb7805 77 echo "Usage: ${0} {start|stop|reload|restart|reload-or-restart|status}"
b312967c
MT
78 exit 1
79 ;;
80esac
81
82# End $rc_base/init.d/tor