Subject: [alpine-aports] [PATCH] testing/docker-registry: Simplify init script, run as dedicated user

From: Christian Kampka <[email-masked]>
Date: Wed, 14 Oct 2015 20:57:16 +0200

---
 testing/docker-registry/APKBUILD              | 13 +++++++-----
 testing/docker-registry/docker-registry.initd | 30 +++++++++------------------
 2 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/testing/docker-registry/APKBUILD b/testing/docker-registry/APKBUILD
index 2077d46..68a2609 100644
--- a/testing/docker-registry/APKBUILD
+++ b/testing/docker-registry/APKBUILD
@@ -1,13 +1,16 @@
-# Maintainer: Chritsian Kampka <christian at kampka dot net>
+# Maintainer: Christian Kampka <christian at kampka dot net>
 pkgname=docker-registry
 pkgver=2.1.1
-pkgrel=0
+pkgrel=1
 pkgdesc="An implementation of the Docker Registry HTTP API V2 for use with docker 1.6+."
 url="https://github.com/docker/distribution"
 arch="x86_64"
 license="Apache 2.0"
 makedepends="git go"
 options="!strip"
+install="$pkgname.pre-install"
+pkguserss="docker-registry"
+pkggroups="docker-registry"
 source="$pkgname-$pkgver.tar.gz::${url}/archive/v${pkgver}.tar.gz
 	docker-registry.initd"
 
@@ -39,8 +42,8 @@ package() {
 	install -v -D -m644 ${_builddir}/LICENSE ${pkgdir}/usr/share/licenses/${pkgname}
 }
 md5sums="956cddde0cbeeb01e15d51d5cc488efb  docker-registry-2.1.1.tar.gz
-7bb346742afa5d44ef15df9855f295b1  docker-registry.initd"
+eaa66ce1509f0b2f257e2919b350fc46  docker-registry.initd"
 sha256sums="80c23c3f223fa44c6cc3f9ac3588f95bc3aaa0561c6fd52f3bbca3fd4c1fbfc0  docker-registry-2.1.1.tar.gz
-c441b0cfac0fbb45fbc78563a07d812704d06ceb0a3b46b0a4377e55b02c5c21  docker-registry.initd"
+d35bfa20956a4dbd6070799fa8a1fd34c100070672e24c9b759df23c69b5431a  docker-registry.initd"
 sha512sums="42986be5077589bb49d61a0766218676bbc085b839ae83a5f39b48df5942ee27b41a66a5bbf282841b68d41cbcd254df04eadd1f2592becd06ba11c84ccb95f2  docker-registry-2.1.1.tar.gz
-4bedcb02d8f8b4f4f778d8c7af889c5d06affae5340a8e6deb228964294ff0257f2035c95c3d65d123a9e1ca9169c29c84a2c8a38c7c0b393b3221442fc447b3  docker-registry.initd"
+338d78b6813825154673c50cd73884297ebdd8c497ec933048dc5bf0863136e7bc308860ce71835d7e48a2b950266a69e60d318e382b18f8352d6c662851ed09  docker-registry.initd"
diff --git a/testing/docker-registry/docker-registry.initd b/testing/docker-registry/docker-registry.initd
index 0f0e34f..4706407 100644
--- a/testing/docker-registry/docker-registry.initd
+++ b/testing/docker-registry/docker-registry.initd
@@ -1,30 +1,20 @@
 #!/sbin/openrc-run
 # $Header: $
 
-DOCKER_REGISTRY_LOGFILE=${DOCKER_REGISTRY_LOGFILE:-/var/log/${SVCNAME}.log}
 DOCKER_REGISTRY_PIDFILE=${DOCKER_REGISTRY_PIDFILE:-/run/${SVCNAME}.pid}
 DOCKER_REGISTRY_BINARY=${DOCKER_REGISTRY_BINARY:-/usr/bin/docker-registry}
 DOCKER_REGISTRY_CONFIG=${DOCKER_REGISTRY_CONFIG:-/etc/docker-registry/config.yml}
+DOCKER_REGISTRY_LOGFILE=${DOCKER_REGISTRY_LOGFILE:-/var/log/docker-registry.log}
 
-start() {
-	checkpath -f -m 0644 -o root:docker "$DOCKER_REGISTRY_LOGFILE"
+command="$DOCKER_REGISTRY_BINARY"
+command_args="$DOCKER_REGISTRY_CONFIG"
+pidfile="$DOCKER_REGISTRY_PIDFILE"
+command_background="true"
+start_stop_daemon_args="--user docker-registry:docker-registry --stdout $DOCKER_REGISTRY_LOGFILE --stderr $DOCKER_REGISTRY_LOGFILE"
+name="Docker Registry"
 
-	ebegin "Starting docker registry"
-	start-stop-daemon --start --background \
-		--exec "$DOCKER_REGISTRY_BINARY" \
-		--pidfile "$DOCKER_PIDFILE" \
-    --make-pid \
-    --background \
-		--stdout "$DOCKER_LOGFILE" \
-		--stderr "$DOCKER_LOGFILE" \
-		-- "$DOCKER_REGISTRY_CONFIG"
-	eend $?
-}
+start_pre() {
+	checkpath --directory --owner docker-registry:docker-registry --mode 0770 /var/lib/registry
 
-stop() {
-	ebegin "Stopping docker daemon"
-	start-stop-daemon --stop \
-		--exec "$DOCKER_BINARY" \
-		--pidfile "$DOCKER_PIDFILE"
-	eend $?
+	checkpath -f -m 0644 -o docker-registry:docker-registry "$DOCKER_REGISTRY_LOGFILE"
 }
-- 
2.6.1

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