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
This commit is contained in:
Alexander Reelsen 2013-05-17 11:14:44 +02:00
parent 2e07af63ba
commit 2485c4890c
5 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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