| Current Path : /proc/288219/root/var/lib/dpkg/info/ |
| Current File : //proc/288219/root/var/lib/dpkg/info/elasticsearch.postinst |
#!/bin/bash -e
#
# This script is executed in the post-installation phase
#
# On Debian,
# $1=configure : is set to 'configure' and if $2 is set, it is an upgrade
#
# On RedHat,
# $1=0 : indicates a removal
# $1=1 : indicates an upgrade
# source the default env file
if [ -f "/etc/default/elasticsearch" ]; then
. "/etc/default/elasticsearch"
fi
export ES_PATH_CONF=${ES_PATH_CONF:-/etc/elasticsearch}
IS_UPGRADE=false
case "$1" in
# Debian ####################################################
configure)
# If $1=configure and $2 is set, this is an upgrade
if [ -n "$2" ]; then
IS_UPGRADE=true
fi
PACKAGE=deb
;;
abort-upgrade|abort-remove|abort-deconfigure)
PACKAGE=deb
;;
# RedHat ####################################################
1)
# If $1=1 this is an install
IS_UPGRADE=false
PACKAGE=rpm
;;
2)
# If $1=1 this is an upgrade
IS_UPGRADE=true
PACKAGE=rpm
;;
*)
echo "post install script called with unknown argument \`$1'" >&2
exit 1
;;
esac
# to pick up /usr/lib/sysctl.d/elasticsearch.conf
if command -v systemctl > /dev/null; then
systemctl restart systemd-sysctl.service || true
fi
if [ "x$IS_UPGRADE" != "xtrue" ]; then
if command -v systemctl >/dev/null; then
echo "### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd"
echo " sudo systemctl daemon-reload"
echo " sudo systemctl enable elasticsearch.service"
echo "### You can start elasticsearch service by executing"
echo " sudo systemctl start elasticsearch.service"
elif command -v chkconfig >/dev/null; then
echo "### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using chkconfig"
echo " sudo chkconfig --add elasticsearch"
echo "### You can start elasticsearch service by executing"
echo " sudo service elasticsearch start"
elif command -v update-rc.d >/dev/null; then
echo "### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using chkconfig"
echo " sudo update-rc.d elasticsearch defaults 95 10"
echo "### You can start elasticsearch service by executing"
echo " sudo /etc/init.d/elasticsearch start"
fi
fi
# the equivalent code for rpm is in posttrans
if [ "$PACKAGE" = "deb" ]; then
if [ ! -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
/usr/share/elasticsearch/bin/elasticsearch-keystore create
chown root:elasticsearch "${ES_PATH_CONF}"/elasticsearch.keystore
chmod 660 "${ES_PATH_CONF}"/elasticsearch.keystore
md5sum "${ES_PATH_CONF}"/elasticsearch.keystore > "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
else
if /usr/share/elasticsearch/bin/elasticsearch-keystore has-passwd --silent ; then
echo "### Warning: unable to upgrade encrypted keystore" 1>&2
echo " Please run elasticsearch-keystore upgrade and enter password" 1>&2
else
/usr/share/elasticsearch/bin/elasticsearch-keystore upgrade
fi
fi
fi
if [ "$RESTART_ON_UPGRADE" = "true" ]; then
echo -n "Restarting elasticsearch service..."
if command -v systemctl >/dev/null; then
systemctl daemon-reload
systemctl restart elasticsearch.service || true
elif [ -x /etc/init.d/elasticsearch ]; then
if command -v invoke-rc.d >/dev/null; then
invoke-rc.d elasticsearch stop || true
invoke-rc.d elasticsearch start || true
else
/etc/init.d/elasticsearch restart || true
fi
# older suse linux distributions do not ship with systemd
# but do not have an /etc/init.d/ directory
# this tries to start the elasticsearch service on these
# as well without failing this script
elif [ -x /etc/rc.d/init.d/elasticsearch ] ; then
/etc/rc.d/init.d/elasticsearch restart || true
fi
echo " OK"
fi
# For SysV compatibility on systemd systems ensure that all rc*.d directories exist
if [ -x /usr/lib/systemd/systemd-sysv-install ]; then
mkdir -p /etc/init.d/rc{0..6}.d
fi
exit 0
# Built for packages-7.17.29 (deb)