diff options
Diffstat (limited to 'net-misc/tor/files/tor.initd-r5')
-rw-r--r-- | net-misc/tor/files/tor.initd-r5 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/net-misc/tor/files/tor.initd-r5 b/net-misc/tor/files/tor.initd-r5 new file mode 100644 index 000000000000..2d2926a9d00f --- /dev/null +++ b/net-misc/tor/files/tor.initd-r5 @@ -0,0 +1,57 @@ +#!/sbin/runscript +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r5,v 1.1 2009/06/03 08:09:04 fauli Exp $ + +opts="${opts} checkconfig reload" +PIDFILE=/var/run/tor/tor.pid +CONFFILE=/etc/tor/torrc + +depend() { + need net +} + +checkconfig() { + # first check that it exists + if [ ! -f ${CONFFILE} ] ; then + eerror "You need to setup ${CONFFILE} first" + eerror "Example is in ${CONFFILE}.sample" + return 1 + fi + + # now verify whether the configuration is valid + /usr/bin/tor --verify-config --User tor -f ${CONFFILE} > /dev/null 2>&1 + if [ $? -eq 0 ] ; then + einfo "Tor configuration (${CONFFILE}) is valid." + return 0 + else + eerror "Tor configuration (${CONFFILE}) not valid." + /usr/bin/tor --verify-config --User tor -f ${CONFFILE} + return 1 + fi +} + +start() { + checkconfig || return 1 + ebegin "Starting Tor" + HOME=/var/lib/tor + start-stop-daemon --start --user tor:tor --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1 + eend $? +} + +stop() { + ebegin "Stopping Tor" + start-stop-daemon --stop --user tor:tor --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}" + eend $? +} + +reload() { + if [ ! -f ${PIDFILE} ]; then + eerror "${SVCNAME} isn't running" + return 1 + fi + checkconfig || return 1 + ebegin "Reloading Tor configuration" + start-stop-daemon --stop --oknodo --signal HUP --pidfile ${PIDFILE} + eend $? +} |