From 55106c14db9a6e57ef823236eccc13dc98316c24 Mon Sep 17 00:00:00 2001 From: Martin Seener Date: Thu, 2 Feb 2017 14:47:21 +0100 Subject: [PATCH 1/3] Fixed install/remove of influxdb on non-systemd Debian/Ubuntu systems For more rationale, please see similar PR on telegraf: https://github.com/influxdata/telegraf/pull/2360 --- CHANGELOG.md | 2 +- package.sh | 2 +- scripts/post-install.sh | 46 +++++++++++++++++++++------------- scripts/post-uninstall.sh | 52 +++++++++++++++++++-------------------- scripts/pre-install.sh | 16 ++++++------ 5 files changed, 64 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a99a59a111e..58b9527a5e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - [#7877](https://github.com/influxdata/influxdb/issues/7877): Fix mapping of types when the measurement uses a regex - [#7888](https://github.com/influxdata/influxdb/pull/7888): Expand query dimensions from the subquery. - [#7910](https://github.com/influxdata/influxdb/issues/7910): Fix EvalType when a parenthesis expression is used. - +- [#7933](https://github.com/influxdata/influxdb/pull/7933): Fixed install/remove of influxdb on non-systemd Debian/Ubuntu systems ## v1.2.0 [2017-01-24] diff --git a/package.sh b/package.sh index a4e34878760..bec2bb27bc1 100755 --- a/package.sh +++ b/package.sh @@ -67,7 +67,7 @@ if [ -z "$FPM" ]; then FPM=`which fpm` fi -GO_VERSION="go1.4.3" +GO_VERSION="go1.7.5" GOPATH_INSTALL= BINS=( influxd diff --git a/scripts/post-install.sh b/scripts/post-install.sh index e77cc3d36a9..aa42d999a74 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -24,8 +24,7 @@ function install_chkconfig { chkconfig --add influxdb } -id influxdb &>/dev/null -if [[ $? -ne 0 ]]; then +if ! id influxdb &>/dev/null; then useradd --system -U -M influxdb -s /bin/false -d $DATA_DIR fi @@ -45,29 +44,42 @@ fi # Distribution-specific logic if [[ -f /etc/redhat-release ]]; then # RHEL-variant logic - which systemctl &>/dev/null - if [[ $? -eq 0 ]]; then - install_systemd + if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then + install_systemd else - # Assuming sysv - install_init - install_chkconfig + # Assuming SysVinit + install_init + # Run update-rc.d or fallback to chkconfig if not available + if which update-rc.d >/dev/null; then + install_update_rcd + else + install_chkconfig + fi fi elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu logic - which systemctl &>/dev/null - if [[ $? -eq 0 ]]; then - install_systemd + if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then + install_systemd else - # Assuming sysv - install_init - install_update_rcd + # Assuming SysVinit + install_init + # Run update-rc.d or fallback to chkconfig if not available + if which update-rc.d >/dev/null; then + install_update_rcd + else + install_chkconfig + fi fi elif [[ -f /etc/os-release ]]; then source /etc/os-release if [[ $ID = "amzn" ]]; then - # Amazon Linux logic - install_init - install_chkconfig + # Amazon Linux logic + install_init + # Run update-rc.d or fallback to chkconfig if not available + if which update-rc.d >/dev/null; then + install_update_rcd + else + install_chkconfig + fi fi fi diff --git a/scripts/post-uninstall.sh b/scripts/post-uninstall.sh index 36dd6dfb775..03b37d83246 100644 --- a/scripts/post-uninstall.sh +++ b/scripts/post-uninstall.sh @@ -18,39 +18,37 @@ function disable_chkconfig { if [[ -f /etc/redhat-release ]]; then # RHEL-variant logic if [[ "$1" = "0" ]]; then - # InfluxDB is no longer installed, remove from init system - rm -f /etc/default/influxdb - - which systemctl &>/dev/null - if [[ $? -eq 0 ]]; then - disable_systemd - else - # Assuming sysv - disable_chkconfig - fi + # InfluxDB is no longer installed, remove from init system + rm -f /etc/default/influxdb + + if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then + disable_systemd + else + # Assuming sysv + disable_chkconfig + fi fi -elif [[ -f /etc/lsb-release ]]; then +elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu logic if [[ "$1" != "upgrade" ]]; then - # Remove/purge - rm -f /etc/default/influxdb - - which systemctl &>/dev/null - if [[ $? -eq 0 ]]; then - disable_systemd - else - # Assuming sysv - disable_update_rcd - fi + # Remove/purge + rm -f /etc/default/influxdb + + if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then + disable_systemd + else + # Assuming sysv + disable_update_rcd + fi fi elif [[ -f /etc/os-release ]]; then source /etc/os-release if [[ $ID = "amzn" ]]; then - # Amazon Linux logic - if [[ "$1" = "0" ]]; then - # InfluxDB is no longer installed, remove from init system - rm -f /etc/default/influxdb - disable_chkconfig - fi + # Amazon Linux logic + if [[ "$1" = "0" ]]; then + # InfluxDB is no longer installed, remove from init system + rm -f /etc/default/influxdb + disable_chkconfig + fi fi fi diff --git a/scripts/pre-install.sh b/scripts/pre-install.sh index d57ff0f71bb..698a7b5ee62 100755 --- a/scripts/pre-install.sh +++ b/scripts/pre-install.sh @@ -3,14 +3,14 @@ if [[ -d /etc/opt/influxdb ]]; then # Legacy configuration found if [[ ! -d /etc/influxdb ]]; then - # New configuration does not exist, move legacy configuration to new location - echo -e "Please note, InfluxDB's configuration is now located at '/etc/influxdb' (previously '/etc/opt/influxdb')." - mv -vn /etc/opt/influxdb /etc/influxdb + # New configuration does not exist, move legacy configuration to new location + echo -e "Please note, InfluxDB's configuration is now located at '/etc/influxdb' (previously '/etc/opt/influxdb')." + mv -vn /etc/opt/influxdb /etc/influxdb - if [[ -f /etc/influxdb/influxdb.conf ]]; then - backup_name="influxdb.conf.$(date +%s).backup" - echo "A backup of your current configuration can be found at: /etc/influxdb/$backup_name" - cp -a /etc/influxdb/influxdb.conf /etc/influxdb/$backup_name - fi + if [[ -f /etc/influxdb/influxdb.conf ]]; then + backup_name="influxdb.conf.$(date +%s).backup" + echo "A backup of your current configuration can be found at: /etc/influxdb/${backup_name}" + cp -a "/etc/influxdb/influxdb.conf" "/etc/influxdb/${backup_name}" + fi fi fi From 8e510010436855ee43c723752d6baafd4bc2f235 Mon Sep 17 00:00:00 2001 From: Martin Seener Date: Thu, 16 Feb 2017 08:52:57 +0100 Subject: [PATCH 2/3] Fixed `which` calls on post-install.sh for CentOS and derivates --- scripts/post-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/post-install.sh b/scripts/post-install.sh index aa42d999a74..6f896266bb2 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -50,7 +50,7 @@ if [[ -f /etc/redhat-release ]]; then # Assuming SysVinit install_init # Run update-rc.d or fallback to chkconfig if not available - if which update-rc.d >/dev/null; then + if which update-rc.d &>/dev/null; then install_update_rcd else install_chkconfig @@ -64,7 +64,7 @@ elif [[ -f /etc/debian_version ]]; then # Assuming SysVinit install_init # Run update-rc.d or fallback to chkconfig if not available - if which update-rc.d >/dev/null; then + if which update-rc.d &>/dev/null; then install_update_rcd else install_chkconfig @@ -76,7 +76,7 @@ elif [[ -f /etc/os-release ]]; then # Amazon Linux logic install_init # Run update-rc.d or fallback to chkconfig if not available - if which update-rc.d >/dev/null; then + if which update-rc.d &>/dev/null; then install_update_rcd else install_chkconfig From a28c68bbd0a3bc74b2086d6beb2cbf91aefe7939 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 26 Apr 2017 20:44:19 +0200 Subject: [PATCH 3/3] Updated package to Go 1.8.1 --- package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.sh b/package.sh index bec2bb27bc1..cf1b0501f9d 100755 --- a/package.sh +++ b/package.sh @@ -67,7 +67,7 @@ if [ -z "$FPM" ]; then FPM=`which fpm` fi -GO_VERSION="go1.7.5" +GO_VERSION="go1.8.1" GOPATH_INSTALL= BINS=( influxd