aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tor/tor.initd
diff options
context:
space:
mode:
authorFrancesco Colista <fcolista@alpinelinux.org>2015-05-22 09:59:02 +0000
committerFrancesco Colista <fcolista@alpinelinux.org>2015-05-22 09:59:02 +0000
commit2e9499059aa562faaa34380d892b5b122e65e305 (patch)
tree83022ad87f889b16edb701462109de4f3c2df96c /testing/tor/tor.initd
parentd52f3e9ceea7adfdbdb7c71309f09946dec74a3f (diff)
downloadaports-2e9499059aa562faaa34380d892b5b122e65e305.tar.gz
aports-2e9499059aa562faaa34380d892b5b122e65e305.tar.bz2
aports-2e9499059aa562faaa34380d892b5b122e65e305.tar.xz
testing/tor: fixes #4217
Diffstat (limited to 'testing/tor/tor.initd')
-rw-r--r--testing/tor/tor.initd67
1 files changed, 49 insertions, 18 deletions
diff --git a/testing/tor/tor.initd b/testing/tor/tor.initd
index 4a26c1dad5..95d02db5d7 100644
--- a/testing/tor/tor.initd
+++ b/testing/tor/tor.initd
@@ -1,30 +1,61 @@
-#!/sbin/runscript
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/Attic/tor.initd-r6,v 1.7 2015/03/20 12:46:13 blueness dead $
-# Sample init.d file for alpine linux.
+extra_commands="checkconfig"
+extra_started_commands="reload"
-name=tor
-daemon=/usr/bin/$name
+PIDFILE=/var/run/tor/tor.pid
+CONFFILE=/etc/tor/torrc
depend() {
- need net
- after firewall
- provide $name
+ 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 -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 -f ${CONFFILE}
+ return 1
+ fi
}
start() {
- ebegin "Starting ${name}"
- start-stop-daemon --start --quiet \
- --pidfile /var/run/${name}.pid \
- -u ${name} \
- --exec ${daemon} -- --runasdaemon 1
- eend $?
+ checkconfig || return 1
+ checkpath -d -m 0755 -o tor /var/run/tor
+ ebegin "Starting Tor"
+ HOME=/var/lib/tor
+ start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1
+ eend $?
}
stop() {
- ebegin "Stopping ${name}"
- start-stop-daemon --stop --quiet \
- --pidfile /var/run/$name.pid \
- --exec ${daemon}
- eend $?
+ ebegin "Stopping Tor"
+ start-stop-daemon --stop --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 --signal HUP --pidfile ${PIDFILE}
+ eend $?
}