Stop sourcing scripts during installation/removal (#28918)

Previously we allowed a lot of customization of Elasticsearch during
package installation (e.g., the username and group). This customization
was achieved by sourcing the env script (e.g.,
/etc/sysconfig/elasticsearch) during installation. Since we no longer
allow such flexibility, we do not need to source these env scripts
during package installation and removal.
This commit is contained in:
Jason Tedor 2018-03-12 13:44:47 -04:00 committed by GitHub
parent b8e165a994
commit f0164cc954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 48 deletions

View File

@ -8,14 +8,6 @@
# $1=0 : indicates a removal # $1=0 : indicates a removal
# $1=1 : indicates an upgrade # $1=1 : indicates an upgrade
# Source the default env file
ES_ENV_FILE="${path.env}"
if [ -f "$ES_ENV_FILE" ]; then
. "$ES_ENV_FILE"
fi
IS_UPGRADE=false IS_UPGRADE=false
case "$1" in case "$1" in

View File

@ -9,9 +9,6 @@
# $1=0 : indicates a removal # $1=0 : indicates a removal
# $1=1 : indicates an upgrade # $1=1 : indicates an upgrade
SOURCE_ENV_FILE=true
REMOVE_DIRS=false REMOVE_DIRS=false
REMOVE_USER_AND_GROUP=false REMOVE_USER_AND_GROUP=false
@ -24,7 +21,6 @@ case "$1" in
purge) purge)
REMOVE_USER_AND_GROUP=true REMOVE_USER_AND_GROUP=true
SOURCE_ENV_FILE=false
;; ;;
failed-upgrade|abort-install|abort-upgrade|disappear|upgrade|disappear) failed-upgrade|abort-install|abort-upgrade|disappear|upgrade|disappear)
;; ;;
@ -45,49 +41,34 @@ case "$1" in
;; ;;
esac esac
# Sets the default values for elasticsearch variables used in this script
LOG_DIR="/var/log/elasticsearch"
PLUGINS_DIR="/usr/share/elasticsearch/plugins"
PID_DIR="/var/run/elasticsearch"
DATA_DIR="/var/lib/elasticsearch"
ES_PATH_CONF="/etc/elasticsearch"
# Source the default env file
if [ "$SOURCE_ENV_FILE" = "true" ]; then
ES_ENV_FILE="${path.env}"
if [ -f "$ES_ENV_FILE" ]; then
. "$ES_ENV_FILE"
fi
fi
if [ "$REMOVE_DIRS" = "true" ]; then if [ "$REMOVE_DIRS" = "true" ]; then
if [ -d "$LOG_DIR" ]; then if [ -d /var/log/elasticsearch ]; then
echo -n "Deleting log directory..." echo -n "Deleting log directory..."
rm -rf "$LOG_DIR" rm -rf /var/log/elasticsearch
echo " OK" echo " OK"
fi fi
if [ -d "$PLUGINS_DIR" ]; then if [ -d /usr/share/elasticsearch/plugins ]; then
echo -n "Deleting plugins directory..." echo -n "Deleting plugins directory..."
rm -rf "$PLUGINS_DIR" rm -rf /usr/share/elasticsearch/plugins
echo " OK" echo " OK"
fi fi
if [ -d "$PID_DIR" ]; then if [ -d /var/run/elasticsearch ]; then
echo -n "Deleting PID directory..." echo -n "Deleting PID directory..."
rm -rf "$PID_DIR" rm -rf /var/run/elasticsearch
echo " OK" echo " OK"
fi fi
# Delete the data directory if and only if empty # Delete the data directory if and only if empty
if [ -d "$DATA_DIR" ]; then if [ -d /var/lib/elasticsearch ]; then
rmdir --ignore-fail-on-non-empty "$DATA_DIR" rmdir --ignore-fail-on-non-empty /var/lib/elasticsearch
fi fi
# delete the conf directory if and only if empty # delete the conf directory if and only if empty
if [ -d "$ES_PATH_CONF" ]; then if [ -d /etc/elasticsearch ]; then
rmdir --ignore-fail-on-non-empty "$ES_PATH_CONF" rmdir --ignore-fail-on-non-empty /etc/elasticsearch
fi fi
fi fi

View File

@ -9,14 +9,6 @@
# $1=1 : indicates an new install # $1=1 : indicates an new install
# $1=2 : indicates an upgrade # $1=2 : indicates an upgrade
# Source the default env file
ES_ENV_FILE="${path.env}"
if [ -f "$ES_ENV_FILE" ]; then
. "$ES_ENV_FILE"
fi
case "$1" in case "$1" in
# Debian #################################################### # Debian ####################################################

View File

@ -9,8 +9,6 @@
# $1=0 : indicates a removal # $1=0 : indicates a removal
# $1=1 : indicates an upgrade # $1=1 : indicates an upgrade
STOP_REQUIRED=false STOP_REQUIRED=false
REMOVE_SERVICE=false REMOVE_SERVICE=false
@ -92,5 +90,4 @@ if [ "$REMOVE_SERVICE" = "true" ]; then
fi fi
fi fi
${scripts.footer} ${scripts.footer}