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

From: Daniele Coli <[email-masked]>
Date: Tue, 10 Nov 2015 04:33:31 +0100

Added init.d script compliant with rc-system. It supports multiple
instances of the service.
By default it looks for /etc/cntlm.conf file. You can define a new
service instance by creating a link to init.d script:
ln -s /etc/init.d/cntlm /etc/init.d/cntlm.<instance_name>
and by creating a new config file in /etc/cntlm.d/<instance_name>.conf
---
 testing/cntlm/APKBUILD    | 17 +++++++++++++----
 testing/cntlm/cntlm.initd | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)
 create mode 100644 testing/cntlm/cntlm.initd

diff --git a/testing/cntlm/APKBUILD b/testing/cntlm/APKBUILD
index 66b4596..ca4609c 100644
--- a/testing/cntlm/APKBUILD
+++ b/testing/cntlm/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=cntlm
 pkgver=0.92.3
-pkgrel=0
+pkgrel=1
 pkgdesc="NTLM Session Response / NTLMv2 authenticating HTTP proxy"
 url="http://cntlm.sourceforge.net/"
 arch="all"
@@ -10,9 +10,11 @@ depends=""
 makedepends=""
 install=""
 subpackages="$pkgname-doc"
-source="http://downloads.sourceforge.net/project/cntlm/cntlm/cntlm%20$pkgver/cntlm-$pkgver.tar.gz"
-
+source="http://downloads.sourceforge.net/project/cntlm/cntlm/cntlm%20$pkgver/cntlm-$pkgver.tar.gz
+	cntlm.initd
+	"
 _builddir="$srcdir"/cntlm-$pkgver
+
 prepare() {
 	local i
 	cd "$_builddir"
@@ -37,6 +39,13 @@ build() {
 package() {
 	cd "$_builddir"
 	make DESTDIR="$pkgdir" install || return 1
+
+	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
 }
 
-md5sums="0d7fcfbfbef0546306b896be246caa88  cntlm-0.92.3.tar.gz"
+md5sums="0d7fcfbfbef0546306b896be246caa88  cntlm-0.92.3.tar.gz
+a8614b3bcd10b8f24429a6676b787360  cntlm.initd"
+sha256sums="9c3ad10924d43f7248df9ecd33cbc033afbd7ea8d9545de0d68a2782fed76298  cntlm-0.92.3.tar.gz
+8023516c6f5352ece48d6241d654c51bc94e873845978184036e27340674979e  cntlm.initd"
+sha512sums="64f97524f1c807dd3bad3f6c1cffb9d3315c720b086336b7379c8c6380c7c483a9c810b40e7e5ea463387476cd718a8e5fcbc1c7103d7128dfc72a8607e6fd39  cntlm-0.92.3.tar.gz
+89982047495c9c62f14e2da5c076ca07942a62e9f87c0d455065c8f702412693ebdfd4e45eeb317a9a7285c4133080b0e7854607ea0daa99ff2420ec15216f97  cntlm.initd"
diff --git a/testing/cntlm/cntlm.initd b/testing/cntlm/cntlm.initd
new file mode 100644
index 0000000..514762c
--- /dev/null
+++ b/testing/cntlm/cntlm.initd
@@ -0,0 +1,39 @@
+#!/sbin/openrc-run
+
+description="Authenticating HTTP accelerator for NTLM secured proxies"
+
+depend() {
+        need localmount net
+        use dns logger
+        after bootmisc firewall
+}
+
+checkconfig() {
+        CNTLM_INSTANCE=${SVCNAME#*.}
+        if [ -n "${CNTLM_INSTANCE}" -a "${SVCNAME}" != "cntlm" ]; then
+                CNTLM_CONF="/etc/cntlm.d/${CNTLM_INSTANCE}.conf"
+                CNTLM_PID="/var/run/cntlm.${CNTLM_INSTANCE}.pid"
+        else
+                CNTLM_CONF="/etc/cntlm.conf"
+                CNTLM_PID="/var/run/cntlm.pid"
+        fi
+        if [ ! -e ${CNTLM_CONF} ]; then
+                eerror "You will need an ${CNTLM_CONF} first"
+                return 1
+        fi
+}
+
+start() {                                                                                                                
+        checkconfig || return 1
+        ebegin "Starting ${SVCNAME}"                        
+        start-stop-daemon --start --exec /usr/sbin/cntlm --pidfile "${CNTLM_PID}" \
+                -- -c "${CNTLM_CONF}" -P "${CNTLM_PID}"
+        eend $?                
+}
+
+stop() {                       
+        checkconfig || return 1     
+        ebegin "Stopping ${SVCNAME}"                                                                             
+        start-stop-daemon --stop --exec /usr/sbin/cntlm --pidfile "${CNTLM_PID}"
+        eend $?                     
+}
-- 
2.6.3

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