Skip to content

Commit

Permalink
Packaging improvements & bugfixes
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
spinscale committed May 17, 2013
1 parent 2e07af6 commit 2485c48
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/deb/init.d/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/rpm/init.d/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/rpm/scripts/postremove
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/rpm/scripts/preinstall
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/rpm/sysconfig/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2485c48

Please sign in to comment.