commit 7344735f992d747b5b59db2dbe18128c4cee0447 Author: Elan Ruusamäe <g...@delfi.ee> Date: Thu May 3 09:33:48 2018 +0300
add initscript eventum-irc-bot.spec | 11 ++++-- eventum-irc.init | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ eventum-irc.sysconfig | 7 ++++ 3 files changed, 117 insertions(+), 3 deletions(-) --- diff --git a/eventum-irc-bot.spec b/eventum-irc-bot.spec index 438c28d..e19c88a 100644 --- a/eventum-irc-bot.spec +++ b/eventum-irc-bot.spec @@ -8,6 +8,8 @@ License: GPL v2+ Group: Networking/Utilities Source0: https://github.com/eventum/irc-bot/archive/master/%{name}-%{version}-p2.tar.gz # Source0-md5: a9bd2dcf229b6212b4ac2a417d10af4c +Source1: eventum-irc.init +Source2: eventum-irc.sysconfig URL: https://github.com/eventum/scm Requires: php(sockets) Requires: php-pear-Net_SmartIRC >= 1.1.9 @@ -48,9 +50,6 @@ kanał używany przez bota, trzeba ręcznie zmodyfikować skrypt bot.php . mv irc-bot-*/* . mv config/{config.dist.php,config.php} -%build -composer install --no-dev -o - %install rm -rf $RPM_BUILD_ROOT install -d $RPM_BUILD_ROOT{%{_sbindir},%{appdir},%{confdir}} @@ -58,6 +57,10 @@ cp -a bin src vendor $RPM_BUILD_ROOT%{appdir} cp -a config/*.php $RPM_BUILD_ROOT%{confdir} ln -s %{confdir} $RPM_BUILD_ROOT%{appdir}/config +install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig} +install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/eventum-irc +cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/eventum-irc + %clean rm -rf $RPM_BUILD_ROOT @@ -66,6 +69,8 @@ rm -rf $RPM_BUILD_ROOT %doc README.md %dir %{confdir} %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{confdir}/config.php +%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/eventum-irc +%attr(754,root,root) /etc/rc.d/init.d/eventum-irc %attr(755,root,root) %{appdir}/bin/irc-bot.php %dir %{appdir} %dir %{appdir}/bin diff --git a/eventum-irc.init b/eventum-irc.init new file mode 100755 index 0000000..792a5f7 --- /dev/null +++ b/eventum-irc.init @@ -0,0 +1,102 @@ +#!/bin/sh +# +# chkconfig: 345 29 71 +# description: Eventum IRC Notification Bot + +# Source function library +. /etc/rc.d/init.d/functions + +# Get network config +. /etc/sysconfig/network + +# Get service config +[ -f /etc/sysconfig/eventum-irc ] && . /etc/sysconfig/eventum-irc + +pidfile=/var/run/eventum/irc_bot.pid +daemon=/usr/share/eventum-irc-bot/bin/irc-bot.php + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then + msg_network_down "Eventum IRC Bot" + exit 1 + fi +else + exit 0 +fi + +start() { + if [ -f /var/lock/subsys/eventum-irc ]; then + msg_already_running "Eventum IRC Bot" + return + fi + + msg_starting "Eventum IRC Bot" + start-stop-daemon --start \ + --exec "$daemon" \ + -m \ + --pidfile $pidfile \ + --chuid http \ + --background + + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + touch /var/lock/subsys/eventum-irc + ok + else + fail + fi +} + +stop() { + if [ ! -f /var/lock/subsys/eventum-irc ]; then + msg_not_running "Eventum IRC Bot" + return + fi + + msg_stopping "Eventum IRC Bot" + if start-stop-daemon --stop --oknodo --pidfile $pidfile; then + rm -f $pidfile /var/lock/subsys/eventum-irc >/dev/null 2>&1 + ok + else + fail + fi +} + +condrestart() { + if [ ! -f /var/lock/subsys/eventum-irc ]; then + msg_not_running "Eventum IRC Bot" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + force-reload) + condrestart 7 + ;; + status) + status --pidfile $pidfile eventum-irc + exit $? + ;; + *) + msg_usage "$0 {start|stop|restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL diff --git a/eventum-irc.sysconfig b/eventum-irc.sysconfig new file mode 100644 index 0000000..2125053 --- /dev/null +++ b/eventum-irc.sysconfig @@ -0,0 +1,7 @@ +# Config file for Eventum IRC Bot + +# nice level +#SERVICE_RUN_NICE_LEVEL="+1" + +# give it 16mb memory and 16m stack +SERVICE_LIMITS="$DEFAULT_SERVICE_LIMITS -m 16384 -s 16384" ================================================================ ---- gitweb: http://git.pld-linux.org/gitweb.cgi/packages/eventum-irc-bot.git/commitdiff/7344735f992d747b5b59db2dbe18128c4cee0447 _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit