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:17:19 UTC
[couchdb-pkg] branch improve-rpm-cookie-setting created (now b356b2c)
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
at b356b2c Improve cookie setup for RPMs
This branch includes the following new commits:
new b356b2c Improve cookie setup for RPMs
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.
[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 b356b2cc0ba352fbc5548d6e2770a87e422a8e6a
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 | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/rpm/SPECS/couchdb.spec.in b/rpm/SPECS/couchdb.spec.in
index 9a3749f..8afc78f 100644
--- a/rpm/SPECS/couchdb.spec.in
+++ b/rpm/SPECS/couchdb.spec.in
@@ -145,18 +145,22 @@ 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;
+ 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;
+ 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}