From: Marcin Krol Date: Mon, 4 Jan 2021 20:08:36 +0000 (+0100) Subject: - added init scripts for proxy and server X-Git-Url: https://git.tld-linux.org/?p=packages%2Fzabbix.git;a=commitdiff_plain;h=edf82675e427f6cb749f8e3802c7d8879b883b6e - added init scripts for proxy and server --- diff --git a/zabbix.spec b/zabbix.spec index 57ef7b0..930f6ef 100644 --- a/zabbix.spec +++ b/zabbix.spec @@ -22,6 +22,8 @@ Source0: https://cdn.zabbix.com/zabbix/sources/stable/5.0/%{name}-%{version}.tar # Source0-md5: e0798bb1b53ab7b451556dc34c3b1827 Source1: %{name}-apache.conf Source2: %{name}_agentd.init +Source3: %{name}_server.init +Source4: %{name}_proxy.init Patch0: tld.patch Patch1: sqlite3_dbname.patch Patch2: always_compile_ipc.patch @@ -332,6 +334,8 @@ cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/zabbix_agentd +install %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/zabbix_server +install %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/zabbix_proxy mv $RPM_BUILD_ROOT%{_appdir}/ui/conf $RPM_BUILD_ROOT%{_sysconfdir}/web ln -s %{_sysconfdir}/web $RPM_BUILD_ROOT%{_appdir}/ui/conf @@ -473,6 +477,7 @@ ln -sf %{_sbindir}/zabbix_proxy-sqlite3 %{_sbindir}/zabbix_proxy || : %defattr(644,root,root,755) %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_proxy.conf %dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_proxy.conf.d +%attr(754,root,root) /etc/rc.d/init.d/zabbix_proxy %ghost %attr(755,root,root) %{_sbindir}/zabbix_proxy %{_mandir}/man8/zabbix_proxy* %endif @@ -501,6 +506,7 @@ ln -sf %{_sbindir}/zabbix_proxy-sqlite3 %{_sbindir}/zabbix_proxy || : %defattr(644,root,root,755) %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_server.conf %dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_server.conf.d +%attr(754,root,root) /etc/rc.d/init.d/zabbix_server %ghost %attr(755,root,root) %{_sbindir}/zabbix_server %{_mandir}/man8/zabbix_server* %endif diff --git a/zabbix_proxy.init b/zabbix_proxy.init new file mode 100755 index 0000000..71bef02 --- /dev/null +++ b/zabbix_proxy.init @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Starts the zabbix_proxy daemon +# +# chkconfig: 345 95 5 +# +# description: zabbix_proxy long service description +# +# processname: zabbix_proxy + +# Source function library +. /etc/rc.d/init.d/functions + +# Get network config +. /etc/sysconfig/network + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down "Zabbix Proxy" + exit 1 + fi +else + exit 0 +fi + +# Get service config - may override defaults +[ -f /etc/sysconfig/zabbix_proxy ] && . /etc/sysconfig/zabbix_proxy + +pidfile="/var/run/zabbix/zabbix_proxy.pid" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/zabbix_proxy ]; then + msg_already_running "Zabbix Proxy" + return + fi + + msg_starting "Zabbix Proxy" + daemon /usr/sbin/zabbix_proxy + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_proxy +} + +stop() { + if [ ! -f /var/lock/subsys/zabbix_proxy ]; then + msg_not_running "Zabbix Proxy" + return + fi + + # Stop daemons. + msg_stopping "Zabbix Proxy" + killproc --pidfile $pidfile zabbix_proxy -TERM + rm -f /var/lock/subsys/zabbix_proxy +} + +condrestart() { + if [ ! -f /var/lock/subsys/zabbix_proxy ]; then + msg_not_running "Zabbix Proxy" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + status) + status --pidfile $pidfile zabbix_proxy + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL diff --git a/zabbix_server.init b/zabbix_server.init new file mode 100755 index 0000000..e98e121 --- /dev/null +++ b/zabbix_server.init @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Starts the zabbix_server daemon +# +# chkconfig: 345 95 5 +# +# description: zabbix_server long service description +# +# processname: zabbix_server + +# Source function library +. /etc/rc.d/init.d/functions + +# Get network config +. /etc/sysconfig/network + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down "Zabbix Server" + exit 1 + fi +else + exit 0 +fi + +# Get service config - may override defaults +[ -f /etc/sysconfig/zabbix_server ] && . /etc/sysconfig/zabbix_server + +pidfile="/var/run/zabbix/zabbix_server.pid" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/zabbix_server ]; then + msg_already_running "Zabbix Server" + return + fi + + msg_starting "Zabbix Server" + daemon /usr/sbin/zabbix_server + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server +} + +stop() { + if [ ! -f /var/lock/subsys/zabbix_server ]; then + msg_not_running "Zabbix Server" + return + fi + + # Stop daemons. + msg_stopping "Zabbix Server" + killproc --pidfile $pidfile zabbix_server -TERM + rm -f /var/lock/subsys/zabbix_server +} + +condrestart() { + if [ ! -f /var/lock/subsys/zabbix_server ]; then + msg_not_running "Zabbix Server" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + status) + status --pidfile $pidfile zabbix_server + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL