Skip to content

Commit

Permalink
Merge pull request influxdata#2205 from influxdata/fix/rpm-verify
Browse files Browse the repository at this point in the history
fix(package): create kapacitor user before install
  • Loading branch information
affo authored May 8, 2019
2 parents 72e88b9 + 8e16d88 commit 5e10277
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
4 changes: 3 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

INIT_SCRIPT = "scripts/init.sh"
SYSTEMD_SCRIPT = "scripts/kapacitor.service"
PREINST_SCRIPT = "scripts/pre-install.sh"
POSTINST_SCRIPT = "scripts/post-install.sh"
POSTUNINST_SCRIPT = "scripts/post-uninstall.sh"
LOGROTATE_CONFIG = "etc/logrotate.d/kapacitor"
BASH_COMPLETION_SH = "usr/share/bash-completion/completions/kapacitor"
DEFAULT_CONFIG = "etc/kapacitor/kapacitor.conf"
PREINST_SCRIPT = None

# Default AWS S3 bucket for uploads
DEFAULT_BUCKET = "dl.influxdata.com/kapacitor/artifacts"
Expand All @@ -54,6 +54,7 @@
fpm_common_args = "-f -s dir --log error \
--vendor {} \
--url {} \
--before-install {} \
--after-install {} \
--after-remove {} \
--license {} \
Expand All @@ -66,6 +67,7 @@
--description \"{}\"".format(
VENDOR,
PACKAGE_URL,
PREINST_SCRIPT,
POSTINST_SCRIPT,
POSTUNINST_SCRIPT,
PACKAGE_LICENSE,
Expand Down
53 changes: 27 additions & 26 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ function enable_chkconfig {
chkconfig --add kapacitor
}

if ! id kapacitor >/dev/null 2>&1; then
useradd --system -U -M kapacitor -s /bin/false -d $DATA_DIR
fi
chmod a+rX $BIN_DIR/kapacitor*

test -f /etc/default/kapacitor || touch /etc/default/kapacitor
Expand All @@ -44,33 +41,37 @@ if [[ -f /etc/redhat-release ]]; then
install_init
# Do not enable service
fi
else
mkdir -p $LOG_DIR
elif [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic

# Ownership for RH-based platforms is set in build.py via the `rmp-attr` option.
# We perform ownership change only for Debian-based systems.
# Moving these lines out of this if statement would make `rmp -V` fail after installation.
test -d $LOG_DIR || mkdir -p $LOG_DIR
test -d $DATA_DIR || mkdir -p $DATA_DIR
chown -R -L kapacitor:kapacitor $LOG_DIR
mkdir -p $DATA_DIR
chown -R -L kapacitor:kapacitor $DATA_DIR
chmod 755 $LOG_DIR
chmod 755 $DATA_DIR

if [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
enable_systemd
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
enable_systemd
else
# Assuming SysV
install_init
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
enable_update_rcd
else
# Assuming SysV
install_init
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
enable_update_rcd
else
enable_chkconfig
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
install_init
# Do not enable service
enable_chkconfig
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
install_init
# Do not enable service
fi
fi
8 changes: 8 additions & 0 deletions scripts/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

DATA_DIR=/var/lib/kapacitor

# create user
if ! id kapacitor >/dev/null 2>&1; then
useradd --system -U -M kapacitor -s /bin/false -d $DATA_DIR
fi

0 comments on commit 5e10277

Please sign in to comment.