From 2485c4890ce82124089062be4b0ee5622b8d54b8 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Fri, 17 May 2013 11:14:44 +0200 Subject: [PATCH] Packaging improvements & bugfixes * RPM: Use the ES_USER variable to set the user (same name as in the debian package now), while retaining backwards compatibility to existing /etc/sysconfig/elasticsearch * RPM: Bugfix: Remove the user when uninstalling the package * RPM: Set an existing homedir when adding the user (allows one to run cronjobs as this user) * DEB & RPM: Unify Required-Start/Required-Stop fields in initscripts --- src/deb/init.d/elasticsearch | 4 ++-- src/rpm/init.d/elasticsearch | 11 ++++++++--- src/rpm/scripts/postremove | 4 ++-- src/rpm/scripts/preinstall | 2 +- src/rpm/sysconfig/elasticsearch | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/deb/init.d/elasticsearch b/src/deb/init.d/elasticsearch index 53c4aa33f4d..aff3f21c169 100644 --- a/src/deb/init.d/elasticsearch +++ b/src/deb/init.d/elasticsearch @@ -11,8 +11,8 @@ # ### BEGIN INIT INFO # Provides: elasticsearch -# Required-Start: $all -# Required-Stop: $all +# Required-Start: $network $named +# Required-Stop: $network $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts elasticsearch diff --git a/src/rpm/init.d/elasticsearch b/src/rpm/init.d/elasticsearch index d798450d7f2..fbeda2280e6 100644 --- a/src/rpm/init.d/elasticsearch +++ b/src/rpm/init.d/elasticsearch @@ -8,8 +8,8 @@ ### BEGIN INIT INFO # Provides: Elasticsearch -# Required-Start: $network -# Required-Stop: $network +# Required-Start: $network $named +# Required-Stop: $network $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: This service manages the elasticsearch daemon @@ -44,6 +44,11 @@ export ES_JAVA_OPTS lockfile=/var/lock/subsys/$prog +# backwards compatibility for old config sysconfig files, pre 0.90.1 +if [ -n $USER ] && [ -z $ES_USER ] ; then + ES_USER=$USER +fi + start() { [ -x $exec ] || exit 5 [ -f $CONF_FILE ] || exit 6 @@ -63,7 +68,7 @@ start() { fi echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" - daemon --user $USER --pidfile $pidfile $exec -p $pidfile -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR + daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR retval=$? echo [ $retval -eq 0 ] && touch $lockfile diff --git a/src/rpm/scripts/postremove b/src/rpm/scripts/postremove index 251b779887d..731be15fe53 100644 --- a/src/rpm/scripts/postremove +++ b/src/rpm/scripts/postremove @@ -1,12 +1,12 @@ echo "Removing elasticsearch user and group if existing" getent passwd elasticsearch > /dev/null -if [ "$?" == "1" ] ; then +if [ "$?" == "0" ] ; then userdel elasticsearch fi getent group elasticsearch >/dev/null -if [ "$?" == "1" ] ; then +if [ "$?" == "0" ] ; then groupdel elasticsearch fi diff --git a/src/rpm/scripts/preinstall b/src/rpm/scripts/preinstall index 70670ed8036..327c8d63e39 100644 --- a/src/rpm/scripts/preinstall +++ b/src/rpm/scripts/preinstall @@ -1,4 +1,4 @@ getent group elasticsearch >/dev/null || groupadd -r elasticsearch getent passwd elasticsearch >/dev/null || \ - useradd -r -g elasticsearch -d /usr/lib/elasticsearch -s /sbin/nologin \ + useradd -r -g elasticsearch -d /usr/share/elasticsearch -s /sbin/nologin \ -c "elasticsearch user" elasticsearch diff --git a/src/rpm/sysconfig/elasticsearch b/src/rpm/sysconfig/elasticsearch index 64867f1a245..7d0184b678b 100644 --- a/src/rpm/sysconfig/elasticsearch +++ b/src/rpm/sysconfig/elasticsearch @@ -37,4 +37,4 @@ CONF_FILE=/etc/elasticsearch/elasticsearch.yml # User to run as, change this to a specific elasticsearch user if possible # Also make sure, this user can write into the log directories in case you change them # This setting only works for the init script, but has to be configured separately for systemd startup -USER=elasticsearch +ES_USER=elasticsearch