Subject: [alpine-aports] [PATCH] testing/vault: simplify init script

From: Christian Kampka <[email-masked]>
Date: Wed, 14 Oct 2015 21:39:52 +0200

---
 testing/vault/APKBUILD          | 16 ++++++++--------
 testing/vault/vault.initd       | 37 +++++++++++--------------------------
 testing/vault/vault.pre-install |  5 +++++
 3 files changed, 24 insertions(+), 34 deletions(-)
 create mode 100644 testing/vault/vault.pre-install

diff --git a/testing/vault/APKBUILD b/testing/vault/APKBUILD
index f2eeae3..76ad5c2 100644
--- a/testing/vault/APKBUILD
+++ b/testing/vault/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer:
 pkgname=vault
 pkgver=0.3.1
-pkgrel=0
+pkgrel=1
 pkgdesc="Vault is a tool for securely accessing secrets."
 url="https://www.vaultproject.io/"
 arch="all"
@@ -10,7 +10,7 @@ license="MPL 2.0"
 depends=""
 depends_dev=""
 makedepends="go godep git $depends_dev"
-#install="$pkgname.pre-install $pkgname.pre-deinstall $pkgname.post-deinstall"
+install="$pkgname.pre-install"
 pkgusers="vault"
 pkggroups="vault"
 subpackages=""
@@ -84,18 +84,18 @@ package() {
     "$pkgdir/etc/${pkgname}.hcl" || return 1
 }
 
-md5sums="86f6ce29bec6c78eca8dc38bb60b8999  vault-0.3.1.tar.gz
+md5sums="aa87b935427faf60d7a50aa758600156  vault-0.3.1.tar.gz
 d299fb9fdf7f66fa6d5e073425487fd9  Godeps.json
 2148a788620484be07e1e24feb1cbd34  vault.confd
 1f7802f479024809856e3be2e44a1b19  vault.hcl
-8b75990815b758db94f400de001cbc81  vault.initd"
-sha256sums="e8ec4b56b8e700d6e88f4909536c6948bd2f9865538afe227450b1ed4b3c8276  vault-0.3.1.tar.gz
+ca400b34773b25367acc85a950c3c887  vault.initd"
+sha256sums="d33328eeb4e5821ac9b68a8a60c11a3eec075a7d70e22d180c4078c3d556d04c  vault-0.3.1.tar.gz
 62284c985b6771d28e37330112701354c7596339d31ccbc4baf0551d8f538360  Godeps.json
 f197536bc5bf4531072c0a5cb17627bf01abd188b0cc2005e0ff1768e6143d32  vault.confd
 cacbd75cbaccf1034cd21d3015797cf0c1c1ce9c7e7ef7c1e4db4b54b92fe696  vault.hcl
-cdbeba798d2b06a178e9c6eb638ff88c4f1c21eaa6c8881a87fac679c8e7c46e  vault.initd"
-sha512sums="83a38fe9860d6d6f62f717a22c5ff27ce2a01e629a3162084c4815512910abe715b55be5eb90ab7bc798793d48149e0fa565f20f2f3fef29cc968d029fbf5b4a  vault-0.3.1.tar.gz
+8274a9c735906980a734a8a720232d8816bfbeb8294d4c96baac2e9885abf6a2  vault.initd"
+sha512sums="2ee2cb681d9caa0c50f43f4050ef9e6ac93cf0170ac2a874f67dcbae1f393d996bff500cd8693a7cf84063a109eeeaf5fb8ce52b4ee5d7deb4da412548517870  vault-0.3.1.tar.gz
 898ea279df93c55c9fc549739530bf63236171afba95f51184f11ce092e6c0ef8bd49382674832c21910ddce92ed9839b3fc582334469c9c783cba352c0e5cf8  Godeps.json
 6f3f30e5c9d9dd5117f18fce0e669f0cd752a6be4910405d6b394f15273372731ee887a5ba4c700293e5b8bc2bf40fd69d4337156f77b03549d2dc2c0a666bec  vault.confd
 8c064aa5dcca84822c1fa85e9d0ff520df46f794b2e9c689a9b4f81f74279387b3aebc08b3ca26cf786c2fcf1a330e765bf5a511074c24f87e5346672346ba1c  vault.hcl
-038f5fd0b7bc84bd8be82a1cb8ac7a5357319bdb77e07936b4072fcb00a30add1cb3744f3a333d2a8b860c821aab0d88249033f61d2a2125de6bb6b2a4c9aef6  vault.initd"
+34993256eb1700ef0738e24227af7732ea81f9e096b34b5f6a282fce364e9c92319c2fc219083eec0185927dde89d565dfcc0d0507bcdbebd3e003027760d447  vault.initd"
diff --git a/testing/vault/vault.initd b/testing/vault/vault.initd
index f539db7..b334546 100644
--- a/testing/vault/vault.initd
+++ b/testing/vault/vault.initd
@@ -1,33 +1,18 @@
 #!/sbin/openrc-run
 
-name=vault
-daemon=/usr/sbin/$name
-daemon_user=$name
-daemon_group=$name
-pidfile="/run/${name}.pid"
+VAULT_LOG_FILE="/var/log/${SVCNAME}.log"
 
-depend() {
-        need net
-        after firewall
-}
-
-start() {
+command=/usr/sbin/${SVCNAME}
+command_args="${vault_opts}"
+command_background="true"
+start_stop_daemon_args="--user ${SVCNAME}:${SVCNAME}  --stdout $VAULT_LOG_FILE --stderr $VAULT_LOG_FILE"
+pidfile="/run/${SVCNAME}.pid"
 
-        checkpath -f -m 0644 -o "${daemon_user}":"${daemon_group}" "$pidfile"
-
-        ebegin "Starting ${name}"
-                start-stop-daemon --start --quiet \
-                        -m --pidfile "$pidfile" \
-                        --user ${daemon_user} --group ${daemon_group} \
-                        -b -1 /dev/null -2 /dev/null \
-                        -k 027 --exec ${daemon} -- ${vault_opts}
-        eend $?
+start_pre() {
+	checkpath -f -m 0644 -o ${SVCNAME}:${SVCNAME} "$VAULT_LOG_FILE"
 }
 
-stop() {
-        ebegin "Stopping ${name}"
-                start-stop-daemon --stop --quiet \
-                        --pidfile "$pidfile" \
-                        --exec ${daemon}
-        eend $?
+depend() {
+        need net
+        after firewall
 }
diff --git a/testing/vault/vault.pre-install b/testing/vault/vault.pre-install
new file mode 100644
index 0000000..93ce40b
--- /dev/null
+++ b/testing/vault/vault.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S vault 2>/dev/null
+adduser -S -H -h /dev/null -s /sbin/nologin -D -G vault vault 2>/dev/null
+exit 0
-- 
2.6.1

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