Skip to content

Commit

Permalink
Fixed install/remove of influxdb on non-systemd Debian/Ubuntu systems
Browse files Browse the repository at this point in the history
For more rationale, please see similar PR on telegraf: influxdata/telegraf#2360
  • Loading branch information
martinseener committed Feb 5, 2017
1 parent 2fe8ed3 commit 55106c1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 29 additions & 17 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
52 changes: 25 additions & 27 deletions scripts/post-uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions scripts/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 55106c1

Please sign in to comment.