X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from dal-a2.localdomain (unknown [74.117.189.115]) by mail.alpinelinux.org (Postfix) with ESMTP id 28FCDDC00D0 for ; Thu, 8 May 2014 13:03:52 +0000 (UTC) Received: from ncopa-desktop.alpinelinux.org (3.203.202.84.customer.cdi.no [84.202.203.3]) (using SSLv3 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: ncopa@tanael.org) by dal-a2.localdomain (Postfix) with ESMTPSA id 6094ABC36D7; Thu, 8 May 2014 13:03:50 +0000 (UTC) Date: Thu, 8 May 2014 15:03:45 +0200 From: Natanael Copa To: Stuart Cardall Cc: alpine-devel@lists.alpinelinux.org Subject: Re: [alpine-devel] [PATCH] testing/namecoin: new aport Message-ID: <20140508150345.192c0881@ncopa-desktop.alpinelinux.org> In-Reply-To: <1399542759-784-1-git-send-email-developer@it-offshore.co.uk> References: <1399542759-784-1-git-send-email-developer@it-offshore.co.uk> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-alpine-linux-musl) X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 8 May 2014 09:52:39 +0000 Stuart Cardall wrote: > This is a revised patch with the sources patched & proposed upstream > to fix a locale bug. > > The post-install script now just generates a random user / pass /port > > This patch provides the namecoin daemon & qt frontend nice! I have some comment below. ... > diff --git a/testing/namecoin/namecoin.confd b/testing/namecoin/namecoin.confd > new file mode 100644 > index 0000000..a2b4542 > --- /dev/null > +++ b/testing/namecoin/namecoin.confd > @@ -0,0 +1,13 @@ > +# Namecoin daemon conf.d file for Alpine Linux > +# > +################################################## > +## If run as a NON root user / group change ## > +## 'pidfile' below to a user writable location ## > +################################################## > +name=namecoind > +daemon=/usr/bin/$name > +config=/etc/namecoin.conf > +user=root > +group=root > +pidfile=/var/run/$name.pid > + I don't think we should run it as root by default. We should create a namecoin user. the init.d script should then checkpath --directory /var/run/namecoin ... and set the pid dir ownership to the user. Does it need a datadir? if so, we should also have a /var/lib/namecoin data dir. > diff --git a/testing/namecoin/namecoin.initd b/testing/namecoin/namecoin.initd > new file mode 100644 > index 0000000..51f509c > --- /dev/null > +++ b/testing/namecoin/namecoin.initd > @@ -0,0 +1,35 @@ > +#!/sbin/runscript > + > +# Namecoin init.d file for Alpine Linux. > + > +config_file=/etc/conf.d/namecoin > + > +depend() { > + need net > + after firewall > +} > + > +check_config() { > + [ -f "$config_file" ] || eend "$config_file is missing" > + [ -f "/usr/bin/namecoind" ] || eend "Namecoin Daemon is not installed" > +} I think this check_config should be removed. the conf.d config should be optional (and init.d should have sensible defaults). The check for executable is not really needed as we ship it with same package and start-stop-daemon will fail if its missing. > + > +start() { > + ebegin "Starting ${name}" > + check_config || return 1 > + start-stop-daemon --start --quiet \ > + --pidfile /var/run/${name}.pid \ > + --user ${user}:${group} \ > + --exec ${daemon} -- -conf=${config} -pid=${pidfile} > + eend $? > +} > + > +stop() { > + ebegin "Stopping ${name}" > + start-stop-daemon --stop --quiet \ > + --pidfile ${pidfile} \ > + --exec ${daemon} > + eend $? > +} > + > + > diff --git a/testing/namecoin/namecoin.post-install b/testing/namecoin/namecoin.post-install > new file mode 100644 > index 0000000..94d2643 > --- /dev/null > +++ b/testing/namecoin/namecoin.post-install > @@ -0,0 +1,53 @@ > +#!/bin/sh > + > +NORMAL="\033[1;0m" > +STRONG="\033[1;1m" > +GREEN="\033[1;32m" > + > +config=$(grep config /etc/conf.d/namecoin |sed 's/config=//') > + > +randgen() { > + output=$(< /dev/urandom tr -dc '0-9a-zA-Z!@#$%^&*_+-' | head -c${1:-$1}) 2>/dev/null > + echo $output > +} > + > +# Generate random port > +randport() { > + n=$RANDOM > + while [ $n -gt 65536 ] && [ $n -lt 1024 ]; do > + n=$RANDOM > + done > + echo $n > +} > + > +# Find unused TCP port > +findRandomTcpPort(){ > + port=$(randport) > + while : > + do > + (echo >/dev/tcp/localhost/$port) &>/dev/null && port=$(randport) || break > + done > + echo $port > +} Why is this needed? cannot the application itself find a random port? > + > +GenPasswd(){ > + sed -i "/rpcuser=/ c \rpcuser=USER-"$(randgen 32)"" $config > + sed -i "/rpcpassword=/ c \rpcpassword=PW-"$(randgen 64)"" $config > + sed -i "/rpcport=/ c \rpcport="$(findRandomTcpPort)"" $config > + print_green "Generated random user / password / port in:" " $config\n" > +} > + > + > +print_green() { > + local prompt="${STRONG}$1${GREEN}$2${NORMAL}" > + printf "${prompt}%s" > +} > + > +if grep -F "changeme" $config 1>/dev/null; then > + GenPasswd > +else > + print_green "Generate a new random username / password / port in: $config ?" " [ y | n ] "; read ans > + if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then > + GenPasswd > + fi > +fi --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---