From 67cd1669ccf2317b3afffbae4b053146409a758c Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Fri, 5 May 2017 14:29:40 -0700 Subject: [PATCH] Add SLES11 support to rpm package (#2768) --- scripts/build.py | 7 ++++--- scripts/init.sh | 4 +++- scripts/post-install.sh | 15 ++++++++------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/build.py b/scripts/build.py index aeaa04fd3..6db34e5ac 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -636,6 +636,10 @@ def package(build_output, pkg_name, version, nightly=False, iteration=1, static= elif package_type not in ['zip', 'tar'] and static or "static_" in arch: logging.info("Skipping package type '{}' for static builds.".format(package_type)) else: + if package_type == 'rpm' and release and '~' in package_version: + package_version, suffix = package_version.split('~', 1) + # The ~ indicatees that this is a prerelease so we give it a leading 0. + package_iteration = "0.%s" % suffix fpm_command = "fpm {} --name {} -a {} -t {} --version {} --iteration {} -C {} -p {} ".format( fpm_common_args, name, @@ -664,9 +668,6 @@ def package(build_output, pkg_name, version, nightly=False, iteration=1, static= if package_type == 'rpm': # rpm's convert any dashes to underscores package_version = package_version.replace("-", "_") - new_outfile = outfile.replace("{}-{}".format(package_version, package_iteration), package_version) - os.rename(outfile, new_outfile) - outfile = new_outfile outfiles.append(os.path.join(os.getcwd(), outfile)) logging.debug("Produced package files: {}".format(outfiles)) return outfiles diff --git a/scripts/init.sh b/scripts/init.sh index 1994deb39..e05fd79ee 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -135,7 +135,9 @@ case $1 in fi log_success_msg "Starting the process" "$name" - if which start-stop-daemon > /dev/null 2>&1; then + if command -v startproc >/dev/null; then + startproc -u "$USER" -g "$GROUP" -p "$pidfile" -q -- "$daemon" -pidfile "$pidfile" -config "$config" -config-directory "$confdir" $TELEGRAF_OPTS + elif which start-stop-daemon > /dev/null 2>&1; then start-stop-daemon --chuid $USER:$GROUP --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR & else su -s /bin/sh -c "nohup $daemon -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR &" $USER diff --git a/scripts/post-install.sh b/scripts/post-install.sh index 8942e3579..75e760fbf 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -24,12 +24,12 @@ function install_chkconfig { chkconfig --add telegraf } +if ! grep "^telegraf:" /etc/group &>/dev/null; then + groupadd -r telegraf +fi + if ! id telegraf &>/dev/null; then - if ! grep "^telegraf:" /etc/group &>/dev/null; then - useradd -r -K USERGROUPS_ENAB=yes -M telegraf -s /bin/false -d /etc/telegraf - else - useradd -r -K USERGROUPS_ENAB=yes -M telegraf -s /bin/false -d /etc/telegraf -g telegraf - fi + useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf fi test -d $LOG_DIR || mkdir -p $LOG_DIR @@ -76,7 +76,7 @@ elif [[ -f /etc/debian_version ]]; then install_systemd /lib/systemd/system/telegraf.service systemctl restart telegraf || echo "WARNING: systemd not running." else - # Assuming SysVinit + # Assuming SysVinit install_init # Run update-rc.d or fallback to chkconfig if not available if which update-rc.d &>/dev/null; then @@ -89,7 +89,7 @@ elif [[ -f /etc/debian_version ]]; then elif [[ -f /etc/os-release ]]; then source /etc/os-release if [[ $ID = "amzn" ]]; then - # Amazon Linux logic + # Amazon Linux logic install_init # Run update-rc.d or fallback to chkconfig if not available if which update-rc.d &>/dev/null; then @@ -97,5 +97,6 @@ elif [[ -f /etc/os-release ]]; then else install_chkconfig fi + /etc/init.d/telegraf restart fi fi