#!/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-r1,v 1.1 2006/01/04 03:38:09 humpback Exp $ depend() { need net } checkconfig() { # first check that it exists if [ ! -f ${CHROOT}/etc/tor/torrc ] ; then eerror "You need to setup ${CHROOT}/etc/tor/torrc first" eerror "Example is in /etc/tor/torrc.sample" return 1 fi } start() { checkconfig || return 1 ebegin "Starting ${CHROOT:+chrooted }Tor" HOME=/var/lib/tor if [ "x${CHROOT}" == "x" ] ; then start-stop-daemon --start --quiet --chuid tor --exec /usr/bin/tor -- --runasdaemon 1 else start-stop-daemon --start --quiet --chuid tor --chroot ${CHROOT} \ --exec /usr/bin/tor -- --runasdaemon 1 fi eend $? } stop() { ebegin "Stopping ${CHROOT:+chrooted }Tor" checkconfig || return 2 if [ "x${CHROOT}" == "x" ] ; then start-stop-daemon --stop --quiet --chuid tor --exec /usr/bin/tor else start-stop-daemon --stop --quiet --chuid tor --pidfile ${CHROOT}${PIDFILE} fi eend $? }