You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2022/05/16 16:36:06 UTC

[couchdb-pkg] branch improve-rpm-cookie-setting updated (b356b2c -> db942ac)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch improve-rpm-cookie-setting
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git


 discard b356b2c  Improve cookie setup for RPMs
     new db942ac  Improve cookie setup for RPMs

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b356b2c)
            \
             N -- N -- N   refs/heads/improve-rpm-cookie-setting (db942ac)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 rpm/SPECS/couchdb.spec.in | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


[couchdb-pkg] 01/01: Improve cookie setup for RPMs

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch improve-rpm-cookie-setting
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit db942ac3406b89523fe32b9e4515ae5fcb7c79b3
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon May 16 11:50:14 2022 -0400

    Improve cookie setup for RPMs
    
    Previously, with an embedded prompt, it was hard to automatically
    provision nodes.
    
    Avoid the interactive TTY prompt by setting a random 48 character (285
    bits of entropy) cookie from /dev/urandom instead. This should help
    automating standalone setups.
    
    Improve clustered setups by allowing users to specify the cookie as an
    environment variable. In this way the cookie may be automaticaly
    provisioned on all the nodes of the cluster during the initial
    install.
    
    Fixes https://github.com/apache/couchdb-pkg/issues/94
---
 rpm/SPECS/couchdb.spec.in | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/rpm/SPECS/couchdb.spec.in b/rpm/SPECS/couchdb.spec.in
index 9a3749f..b53b738 100644
--- a/rpm/SPECS/couchdb.spec.in
+++ b/rpm/SPECS/couchdb.spec.in
@@ -145,18 +145,24 @@ if ! /usr/bin/getent passwd couchdb > /dev/null; then /usr/sbin/adduser \
 
 %post
 if %{__grep} -q "^-setcookie monster$" /opt/%{name}/etc/vm.args; then
-  echo "Please enter a cookie value for this installation: " >/dev/tty
-  if exec </dev/tty; then
-    read cookie;
+  # -v is a bash 4.2+ feature
+  if [ -v COUCHDB_COOKIE ]; then
+    echo "Using defined COUCHDB_COOKIE value."
+    cookie=${COUCHDB_COOKIE}
+  else
+    echo "Generating random cookie value."
+    cookie=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head --bytes 48)
   fi
-  echo "Writing $cookie to vm.args..."
   %{__sed} -i "s/^-setcookie monster.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
 elif %{__grep} -q "^[# ]*-setcookie$" /opt/%{name}/etc/vm.args; then
-  echo "Please enter a cookie value for this installation: " >/dev/tty
-  if exec </dev/tty; then
-    read cookie;
+  # -v is a bash 4.2+ feature
+  if [ -v COUCHDB_COOKIE ]; then
+    echo "Using defined COUCHDB_COOKIE value."
+    cookie=${COUCHDB_COOKIE}
+  else
+    echo "Generating random cookie value."
+    cookie=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head --bytes 48)
   fi
-  echo "Writing $cookie to vm.args..."
   %{__sed} -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
 fi
 %{__chown} -R couchdb:couchdb /opt/%{name}