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/18 12:04:13 UTC
[couchdb-pkg] branch main updated: Improve cookie setup for RPMs
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git
The following commit(s) were added to refs/heads/main by this push:
new 227f6b4 Improve cookie setup for RPMs
227f6b4 is described below
commit 227f6b4fb6c5f3d6890f56449cf465b7eb948df0
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..cfec522 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/random | 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/random | 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}