From fa22b1f96f5c68104ff269699f3660bb16db562f Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 2 Jul 2020 17:48:47 +0100 Subject: [PATCH] Address review comments --- rpm/st2chatops.init | 160 -------------------------------------------- rpm/st2chatops.spec | 12 ---- 2 files changed, 172 deletions(-) delete mode 100644 rpm/st2chatops.init diff --git a/rpm/st2chatops.init b/rpm/st2chatops.init deleted file mode 100644 index 456655a..0000000 --- a/rpm/st2chatops.init +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/sh -# -### BEGIN INIT INFO -# Provides: st2chatops -# Required-Start: $local_fs $network $named $remote_fs $syslog -# Required-Stop: $local_fs $network $named $remote_fs $syslog -# Short-Description: st2chatops component -# Description: st2chatops - StackStorm service st2chatops -### END INIT INFO - -# st2chatops This shell script takes care of starting and stopping -# st2chatops daemon. -# chkconfig: - 85 15 -# description: st2chatops - StackStorm service st2chatops -# processname: st2chatops - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -DESC="st2chatops" -NAME=st2chatops -DAEMON=/opt/stackstorm/chatops/bin/hubot -DAEMON_ARGS="" -WORKING_DIRECTORY=/opt/stackstorm/chatops -PIDFILE=/var/run/$NAME.pid -LOGFILE=/var/log/st2/$NAME.log -RUNAS_USER="st2" -RUNAS_GROUP="st2" - -lockfile=/var/lock/subsys/$NAME - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 5 - -# Read configuration variable file if it is present -set -o allexport -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME -set +o allexport -DAEMON_ARGS="" - - -# Resemble redhatish daemon behaviour but with group and user available -# -nohup_start() { - local nicelevel corelimit - local pid base= nice= bg= - local runas_user="${RUNAS_USER:-root}" - local runas_group="${RUNAS_GROUP:-root}" - nicelevel=0 - - base=${1##*/} - __pids_var_run "$base" - - [ -n "$pid" ] && return - - # make sure it doesn't core dump anywhere unless requested - corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}" - # if they set NICELEVEL in /etc/sysconfig/foo, honor it - [ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL" - - # Echo daemon - [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base" - - # make sure log file exists and owned by the same user - touch $LOGFILE && chown $runas_user:$runas_group $LOGFILE - - # And start it up. - $nice runuser -s /bin/bash -g $runas_group $runas_user -c "$corelimit >/dev/null 2>&1 ; cd $WORKING_DIRECTORY && nohup >$LOGFILE 2>&1 $* &" -} - -# Write pid of a running daemon into the pidfile -# -write_pidfile() { - local currentpid daemon=$1 pidfile=$2 base - base=${daemon##*/} - pidfile=${pidfile:-/var/run/$base.pid} - - sleep 0.1 - currentpid=$(ps -A xo pid,cmd | grep "\bbin/$base\b" | tail -n1 | awk '{print $1}') - [ -n "$currentpid" ] && echo $currentpid > $pidfile -} - -start() { - echo -n $"Starting $NAME: " - nohup_start $DAEMON $DAEMON_ARGS - write_pidfile $DAEMON $PIDFILE - rh_status_q - retval=$? - [ $retval -eq 0 ] && success $"$NAME startup" || failure $"$NAME startup" - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $NAME: " - killproc -p $PIDFILE $DAEMON - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status $NAME -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? diff --git a/rpm/st2chatops.spec b/rpm/st2chatops.spec index ec2f4c1..53961dc 100644 --- a/rpm/st2chatops.spec +++ b/rpm/st2chatops.spec @@ -38,10 +38,6 @@ Requires: /usr/bin/env done \ %{nil} -%if 0%{?_unitdir:1} - %define use_systemd 1 -%endif - %description Package providing StackStorm ChatOps functionality: bundled, tested and ready to use Hubot @@ -57,11 +53,7 @@ Requires: /usr/bin/env %install %debian_dirs %make_install -%if 0%{?use_systemd} install -D -p -m0644 %{_builddir}/rpm/st2chatops.service %{buildroot}%{_unitdir}/st2chatops.service -%else - install -D -p -m0755 %{_builddir}/rpm/st2chatops.init %{buildroot}%{_sysconfdir}/rc.d/init.d/st2chatops -%endif %clean rm -rf %{buildroot} @@ -73,11 +65,7 @@ Requires: /usr/bin/env /opt/stackstorm/chatops/* %attr(755, st2, root) %{_localstatedir}/log/st2 %config(noreplace) %{_sysconfdir}/logrotate.d/st2chatops -%if 0%{?use_systemd} %{_unitdir}/st2chatops.service -%else - %{_sysconfdir}/rc.d/init.d/st2chatops -%endif %config(noreplace) /opt/stackstorm/chatops/st2chatops.env %config(noreplace) /opt/stackstorm/chatops/external-scripts.json