Bug#930113: tor: please provide runscript file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Bug#930113: tor: please provide runscript file

Dmitry Bogatov-3
Source: tor
Version: 0.4.0.5-1
Severity: wishlist
Tags: patch
User: [hidden email]
Usertags: runscript

Dear maintainer,

please include native script for runit init system into 'tor'.
Below is diff aganist latest package release (0.4.0.5-1).

Here are some links:

 * http://smarden.org/runit -- more information about 'runit'
 * https://bugs.debian.org/746715 -- technical committe position
   on support of init systems, other then sysvinit.

From d7ca30748d31efaf37dbd37e9cf8f1e7464ed84f Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <[hidden email]>
Date: Thu, 6 Jun 2019 10:00:28 +0000
Subject: [PATCH] Add integration for runit init

---
 debian/control                                |  3 ++-
 debian/rules                                  |  1 +
 debian/tor.install                            |  2 ++
 debian/tor.runit                              |  1 +
 debian/tor.runscript/conf/MAX_FILEDESCRIPTORS |  1 +
 debian/tor.runscript/run                      | 23 +++++++++++++++++++
 6 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 debian/tor.runit
 create mode 100644 debian/tor.runscript/conf/MAX_FILEDESCRIPTORS
 create mode 100644 debian/tor.runscript/run

diff --git a/debian/control b/debian/control
index 74ba641..e240b05 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: tor
 Section: net
 Priority: optional
 Maintainer: Peter Palfrader <[hidden email]>
-Build-Depends: debhelper (>= 9.20160114), quilt, libssl-dev, zlib1g-dev, libevent-dev (>= 1.1), asciidoc (>= 8.2), docbook-xml, docbook-xsl, xmlto, dh-apparmor, libseccomp-dev [amd64 i386], dh-systemd [linux-any], libsystemd-dev [linux-any], pkg-config [linux-any], libcap-dev [linux-any], dh-autoreconf, liblzma-dev, libzstd-dev
+Build-Depends: debhelper (>= 9.20160114), quilt, libssl-dev, zlib1g-dev, libevent-dev (>= 1.1), asciidoc (>= 8.2), docbook-xml, docbook-xsl, xmlto, dh-apparmor, libseccomp-dev [amd64 i386], dh-systemd [linux-any], libsystemd-dev [linux-any], pkg-config [linux-any], libcap-dev [linux-any], dh-autoreconf, liblzma-dev, libzstd-dev, dh-runit (>= 2.8.8)
 Build-Conflicts: libnacl-dev, libseccomp-dev [!amd64 !i386]
 Standards-Version: 3.9.8
 Homepage: https://www.torproject.org/
@@ -14,6 +14,7 @@ Architecture: any
 Depends: ${shlibs:Depends}, adduser, ${misc:Depends}, lsb-base
 Pre-Depends: ${misc:Pre-Depends}
 Conflicts: libssl0.9.8 (<< 0.9.8g-9)
+Breaks: ${runit:Breaks}
 Recommends: logrotate, tor-geoipdb, torsocks
 Suggests: mixmaster, torbrowser-launcher, socat, tor-arm, apparmor-utils, tor-arm, obfs4proxy
 Description: anonymizing overlay network for TCP
diff --git a/debian/rules b/debian/rules
index 710d166..22c093a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -26,6 +26,7 @@ endif
  $@ \
  --with quilt \
  --with autoreconf \
+ --with runit \
  $(dhoptions) \
  --builddirectory=build \
  --parallel
diff --git a/debian/tor.install b/debian/tor.install
index 97da1ca..566d16a 100644
--- a/debian/tor.install
+++ b/debian/tor.install
@@ -11,3 +11,5 @@ debian/systemd/tor.service lib/systemd/system
 debian/systemd/tor@.service lib/systemd/system
 debian/systemd/[hidden email] lib/systemd/system
 debian/systemd/tor-generator lib/systemd/system-generators
+
+debian/tor.runscript/conf/* /etc/tor/conf
diff --git a/debian/tor.runit b/debian/tor.runit
new file mode 100644
index 0000000..5ca5bca
--- /dev/null
+++ b/debian/tor.runit
@@ -0,0 +1 @@
+debian/tor.runscript name=tor,logscript,since=0.3.5.8-1+runit
diff --git a/debian/tor.runscript/conf/MAX_FILEDESCRIPTORS b/debian/tor.runscript/conf/MAX_FILEDESCRIPTORS
new file mode 100644
index 0000000..252cb66
--- /dev/null
+++ b/debian/tor.runscript/conf/MAX_FILEDESCRIPTORS
@@ -0,0 +1 @@
+8192
diff --git a/debian/tor.runscript/run b/debian/tor.runscript/run
new file mode 100644
index 0000000..b6854c6
--- /dev/null
+++ b/debian/tor.runscript/run
@@ -0,0 +1,23 @@
+#!/usr/bin/env /lib/runit/invoke-run
+readonly daemon=/usr/bin/tor
+exec 2>&1
+
+ulimit -n "${MAX_FILEDESCRIPTORS}"
+
+# default invocation
+set -- "${daemon}"                                             \
+ --defaults-torrc /usr/share/tor/tor-service-defaults-torrc \
+ -f /etc/tor/torrc                                          \
+ --Log 'notice stdout'                                      \
+ --RunAsDaemon 0
+
+if ! "$@" --verify-config ; then
+ echo "persistent error: Tor configuration is not valid"
+ exec sv down tor
+fi
+
+if aa-status --enabled ; then
+ set -- aa-exec --profile=system_tor -- "$@"
+fi
+
+exec "$@"