| 1 |
#!/sbin/runscript
|
| 2 |
# Copyright 1999-2011 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-r6,v 1.5 2011/09/14 10:53:02 blueness Exp $
|
| 5 |
|
| 6 |
extra_commands="checkconfig"
|
| 7 |
extra_started_commands="reload"
|
| 8 |
|
| 9 |
PIDFILE=/var/run/tor/tor.pid
|
| 10 |
CONFFILE=/etc/tor/torrc
|
| 11 |
|
| 12 |
depend() {
|
| 13 |
need net
|
| 14 |
}
|
| 15 |
|
| 16 |
checkconfig() {
|
| 17 |
# first check that it exists
|
| 18 |
if [ ! -f ${CONFFILE} ] ; then
|
| 19 |
eerror "You need to setup ${CONFFILE} first"
|
| 20 |
eerror "Example is in ${CONFFILE}.sample"
|
| 21 |
return 1
|
| 22 |
fi
|
| 23 |
|
| 24 |
# now verify whether the configuration is valid
|
| 25 |
/usr/bin/tor --verify-config -f ${CONFFILE} > /dev/null 2>&1
|
| 26 |
if [ $? -eq 0 ] ; then
|
| 27 |
einfo "Tor configuration (${CONFFILE}) is valid."
|
| 28 |
return 0
|
| 29 |
else
|
| 30 |
eerror "Tor configuration (${CONFFILE}) not valid."
|
| 31 |
/usr/bin/tor --verify-config -f ${CONFFILE}
|
| 32 |
return 1
|
| 33 |
fi
|
| 34 |
}
|
| 35 |
|
| 36 |
start() {
|
| 37 |
checkconfig || return 1
|
| 38 |
checkpath -d -m 0755 -o tor:tor /var/run/tor
|
| 39 |
ebegin "Starting Tor"
|
| 40 |
HOME=/var/lib/tor
|
| 41 |
start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1
|
| 42 |
eend $?
|
| 43 |
}
|
| 44 |
|
| 45 |
stop() {
|
| 46 |
ebegin "Stopping Tor"
|
| 47 |
start-stop-daemon --stop --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
|
| 48 |
eend $?
|
| 49 |
}
|
| 50 |
|
| 51 |
reload() {
|
| 52 |
if [ ! -f ${PIDFILE} ]; then
|
| 53 |
eerror "${SVCNAME} isn't running"
|
| 54 |
return 1
|
| 55 |
fi
|
| 56 |
checkconfig || return 1
|
| 57 |
ebegin "Reloading Tor configuration"
|
| 58 |
start-stop-daemon --signal HUP --pidfile ${PIDFILE}
|
| 59 |
eend $?
|
| 60 |
}
|