Subject: [alpine-aports] [PATCH] testing/redsocks: Added startup init.d script

From: Daniele Coli <[email-masked]>
Date: Sun, 14 Feb 2016 18:43:47 +0100

---
 testing/redsocks/APKBUILD       | 15 ++++++++++-----
 testing/redsocks/redsocks.initd | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 testing/redsocks/redsocks.initd

diff --git a/testing/redsocks/APKBUILD b/testing/redsocks/APKBUILD
index 625a266..1e93a6a 100644
--- a/testing/redsocks/APKBUILD
+++ b/testing/redsocks/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Francesco Colista <[email-masked]>
 pkgname=redsocks
 pkgver=0.4
-pkgrel=0
+pkgrel=1
 pkgdesc="Transparent redirector of any TCP connection to proxy using your firewall"
 url="http://darkk.net.ru/redsocks"
 arch="all"
@@ -12,7 +12,8 @@ depends_dev="libevent-dev iptables-dev"
 makedepends="$depends_dev"
 install=""
 subpackages=""
-source="https://github.com/darkk/$pkgname/archive/release-$pkgver.zip"
+source="https://github.com/darkk/$pkgname/archive/release-$pkgver.zip
+	redsocks.initd"
 _builddir="$srcdir"/$pkgname-release-$pkgver
 prepare() {
 	local i
@@ -32,9 +33,13 @@ build() {
 package() {
 	cd "$_builddir"
 	install -Dm755 redsocks "$pkgdir/usr/bin/redsocks"
+	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
 	install -Dm644 redsocks.conf.example "$pkgdir"/etc/$pkgname/redsocks.conf
 }
 
-md5sums="eb84f51f76530842a5d734795f4a1b77  release-0.4.zip"
-sha256sums="d0ea872bb42b86e6ad3a6bdb46a2c6b822713b41b00c9f6f2ad2b4ec81d5202f  release-0.4.zip"
-sha512sums="029d06fdee382052c727bfd6a2362f68f6156bdd2928de18b425207c524763d3dde56ccc49e0673889a67ef7b16f061a63f44d04895a99195aaf4bace731cc50  release-0.4.zip"
+md5sums="1f29854b20d931f2f4590a3c832ee3ec  release-0.4.zip
+ebf676a98e9798731c621900ad50e1bf  redsocks.initd"
+sha256sums="eedb7fd6cb00b207938c463c5eda63aae7cec1a43715b7e1c0106bd6fdaea729  release-0.4.zip
+42f7d2318b8e6e2601fecb8310f0e9d1b6b4ed442b872b4cdea406e84e154b5b  redsocks.initd"
+sha512sums="bd88684f2964a7f94b6965f445379479f2a70938490a28bcacbeafcad911cbbf40a640cf37ff5fcbc0475075dbf1858bbb905cd5db9519ff76d900e9b35e1242  release-0.4.zip
+e2da5e1c5025a46c1f64daec4017d34a700d9d269cc463ef9395989c73d9aeefad222409f6cdfba92742011c4ef4a9edef554706f3353dfd0f7bc526247551c5  redsocks.initd"
diff --git a/testing/redsocks/redsocks.initd b/testing/redsocks/redsocks.initd
new file mode 100644
index 0000000..592f193
--- /dev/null
+++ b/testing/redsocks/redsocks.initd
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+
+description="Transparent socks redirector"
+
+CFGFILE="/etc/redsocks/${SVCNAME}.conf"
+PIDFILE="/var/run/${SVCNAME}.pid"
+
+depend() {
+        need localmount net
+        use dns logger
+        after bootmisc firewall
+}
+
+checkconfig() {
+	/usr/bin/redsocks -t -c ${CFGFILE}
+        if [ "$?" -gt 0 ]; then
+                eerror "Problem on configuration file ${CFGFILE}"
+                return 1
+        fi
+}
+
+start() {
+        checkconfig || return 1
+        ebegin "Starting ${SVCNAME}"
+        start-stop-daemon --start --exec /usr/bin/redsocks --pidfile "${PIDFILE}" \
+                -- -c "${CFGFILE}" -p "${PIDFILE}"
+        eend $?
+}
+
+stop() {
+        checkconfig || return 1
+        ebegin "Stopping ${SVCNAME}"
+        start-stop-daemon --stop --exec /usr/bin/redsocks --pidfile "${PIDFILE}"
+        eend $?
+}
-- 
2.7.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---