/[gentoo-x86]/net-misc/tor/files/tor.initd-r7
Gentoo

Contents of /net-misc/tor/files/tor.initd-r7

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Dec 23 17:26:49 2014 UTC (3 years, 11 months ago) by blueness
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -2 lines
Fix cosmetics in tor.initd-r7

(Portage version: 2.2.14/cvs/Linux x86_64, signed Manifest commit with key 0xF52D4BBA)

1 #!/sbin/runscript
2 # Copyright 1999-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r7,v 1.1 2014/09/23 23:14:00 blueness Exp $
5
6 PIDFILE=/var/run/tor/tor.pid
7 CONFFILE=/etc/tor/torrc
8 GRACEFUL_TIMEOUT=${GRACEFUL_TIMEOUT:-60}
9
10 # See bug #523552, and https://trac.torproject.org/projects/tor/ticket/5525
11 # Graceful = wait 30 secs or so until all connections are properly closed.
12 extra_commands="checkconfig"
13 extra_started_commands="graceful gracefulstop reload"
14 description="Anonymizing overlay network for TCP"
15 description_checkconfig="Check for valid config file."
16 description_reload="Reload the configuration."
17 description_graceful="Gracefully restart."
18 description_gracefulstop="Gracefully stop."
19
20 depend() {
21 need net
22 }
23
24 checkconfig() {
25 # first check that it exists
26 if [ ! -f ${CONFFILE} ] ; then
27 eerror "You need to setup ${CONFFILE} first"
28 eerror "Example is in ${CONFFILE}.sample"
29 return 1
30 fi
31
32 # now verify whether the configuration is valid
33 /usr/bin/tor --verify-config -f ${CONFFILE} > /dev/null 2>&1
34 if [ $? -eq 0 ] ; then
35 einfo "Tor configuration (${CONFFILE}) is valid."
36 return 0
37 else
38 eerror "Tor configuration (${CONFFILE}) not valid."
39 /usr/bin/tor --verify-config -f ${CONFFILE}
40 return 1
41 fi
42 }
43
44 start() {
45 checkconfig || return 1
46 checkpath -d -m 0755 -o tor:tor /var/run/tor
47 ebegin "Starting Tor"
48 HOME=/var/lib/tor
49 start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1
50 eend $?
51 }
52
53 stop() {
54 ebegin "Stopping Tor"
55 start-stop-daemon --stop --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
56 eend $?
57 }
58
59 graceful() {
60 gracefulstop
61 start
62 eend $?
63 }
64
65 gracefulstop() {
66 local rc=0
67 ebegin "Gracefully stopping Tor"
68 ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
69 start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
70 rc=$?
71 eend "done"
72 eend $rc
73 }
74
75 reload() {
76 if [ ! -f ${PIDFILE} ]; then
77 eerror "${SVCNAME} isn't running"
78 return 1
79 fi
80 checkconfig || return 1
81 ebegin "Reloading Tor configuration"
82 start-stop-daemon --signal HUP --pidfile ${PIDFILE}
83 eend $?
84 }

  ViewVC Help
Powered by ViewVC 1.1.20