Disable service in pre-uninstall
Today in the packaging removal scripts, we disable the service in post-uninstall. Yet, this happens after service files have been erased. On some systems, this can cause the service disable to fail leaving behind state causing the service to be enabled on subsequent installs. This commit moves the service disabling to the pre-uninstall script to prevent this issue. Relates #19328
This commit is contained in:
parent
2a91a6ac37
commit
d29d2f8793
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
SOURCE_ENV_FILE=true
|
SOURCE_ENV_FILE=true
|
||||||
REMOVE_DIRS=false
|
REMOVE_DIRS=false
|
||||||
REMOVE_SERVICE=false
|
|
||||||
REMOVE_USER_AND_GROUP=false
|
REMOVE_USER_AND_GROUP=false
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -21,7 +20,6 @@ case "$1" in
|
||||||
# Debian ####################################################
|
# Debian ####################################################
|
||||||
remove)
|
remove)
|
||||||
REMOVE_DIRS=true
|
REMOVE_DIRS=true
|
||||||
REMOVE_SERVICE=true
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
purge)
|
purge)
|
||||||
|
@ -34,7 +32,6 @@ case "$1" in
|
||||||
# RedHat ####################################################
|
# RedHat ####################################################
|
||||||
0)
|
0)
|
||||||
REMOVE_DIRS=true
|
REMOVE_DIRS=true
|
||||||
REMOVE_SERVICE=true
|
|
||||||
REMOVE_USER_AND_GROUP=true
|
REMOVE_USER_AND_GROUP=true
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
|
@ -65,20 +62,6 @@ if [ "$SOURCE_ENV_FILE" = "true" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$REMOVE_SERVICE" = "true" ]; then
|
|
||||||
if command -v systemctl >/dev/null; then
|
|
||||||
systemctl disable elasticsearch.service > /dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v chkconfig >/dev/null; then
|
|
||||||
chkconfig --del elasticsearch 2> /dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v update-rc.d >/dev/null; then
|
|
||||||
update-rc.d elasticsearch remove >/dev/null || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$REMOVE_DIRS" = "true" ]; then
|
if [ "$REMOVE_DIRS" = "true" ]; then
|
||||||
|
|
||||||
if [ -d "$LOG_DIR" ]; then
|
if [ -d "$LOG_DIR" ]; then
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
|
|
||||||
|
|
||||||
STOP_REQUIRED=false
|
STOP_REQUIRED=false
|
||||||
|
REMOVE_SERVICE=false
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
||||||
# Debian ####################################################
|
# Debian ####################################################
|
||||||
remove)
|
remove)
|
||||||
STOP_REQUIRED=true
|
STOP_REQUIRED=true
|
||||||
|
REMOVE_SERVICE=true
|
||||||
;;
|
;;
|
||||||
upgrade)
|
upgrade)
|
||||||
if [ "$RESTART_ON_UPGRADE" = "true" ]; then
|
if [ "$RESTART_ON_UPGRADE" = "true" ]; then
|
||||||
|
@ -30,6 +32,7 @@ case "$1" in
|
||||||
# RedHat ####################################################
|
# RedHat ####################################################
|
||||||
0)
|
0)
|
||||||
STOP_REQUIRED=true
|
STOP_REQUIRED=true
|
||||||
|
REMOVE_SERVICE=true
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
# Dont do anything on upgrade, because the preun script in redhat gets executed after the postinst (madness!)
|
# Dont do anything on upgrade, because the preun script in redhat gets executed after the postinst (madness!)
|
||||||
|
@ -64,6 +67,20 @@ if [ "$STOP_REQUIRED" = "true" ]; then
|
||||||
echo " OK"
|
echo " OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$REMOVE_SERVICE" = "true" ]; then
|
||||||
|
if command -v systemctl >/dev/null; then
|
||||||
|
systemctl disable elasticsearch.service > /dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v chkconfig >/dev/null; then
|
||||||
|
chkconfig --del elasticsearch 2> /dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v update-rc.d >/dev/null; then
|
||||||
|
update-rc.d elasticsearch remove >/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
SCRIPTS_DIR="/etc/elasticsearch/scripts"
|
SCRIPTS_DIR="/etc/elasticsearch/scripts"
|
||||||
# delete the scripts directory if and only if empty
|
# delete the scripts directory if and only if empty
|
||||||
if [ -d "$SCRIPTS_DIR" ]; then
|
if [ -d "$SCRIPTS_DIR" ]; then
|
||||||
|
|
Loading…
Reference in New Issue