Created
January 6, 2013 10:26
-
-
Save t0d0r/4466457 to your computer and use it in GitHub Desktop.
zabbix-agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: zabbix-agent | |
| # Required-Start: $remote_fs $network | |
| # Required-Stop: $remote_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Start zabbix-agent daemon | |
| ### END INIT INFO | |
| set -e | |
| NAME=zabbix_agentd | |
| DAEMON=/usr/sbin/$NAME | |
| DESC="Zabbix agent" | |
| test -x $DAEMON || exit 0 | |
| DIR=/var/run/zabbix-agent | |
| PID=$DIR/$NAME.pid | |
| RETRY=15 | |
| if test ! -d "$DIR"; then | |
| mkdir "$DIR" | |
| chown -R zabbix:zabbix "$DIR" | |
| fi | |
| export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
| # define LSB log_* functions. | |
| . /lib/lsb/init-functions | |
| case "$1" in | |
| start) | |
| log_daemon_msg "Starting $DESC" "$NAME" | |
| start-stop-daemon --oknodo --start --pidfile $PID \ | |
| --exec $DAEMON >/dev/null 2>&1 | |
| case "$?" in | |
| 0) log_end_msg 0 ;; | |
| *) log_end_msg 1; exit 1 ;; | |
| esac | |
| ;; | |
| stop) | |
| log_daemon_msg "Stopping $DESC" "$NAME" | |
| start-stop-daemon --oknodo --stop --exec $DAEMON --retry $RETRY | |
| case "$?" in | |
| 0) log_end_msg 0 ;; | |
| *) log_end_msg 1; exit 1 ;; | |
| esac | |
| ;; | |
| status) | |
| ls -l /proc/`cat $PID`/exe &> /dev/null | |
| if [ $? -eq 0 ]; then | |
| echo "$DESC is running" | |
| exit 0 | |
| else | |
| echo "$DESC is NOT running" | |
| exit 1 | |
| fi | |
| ;; | |
| restart|force-reload) | |
| $0 stop | |
| $0 start | |
| ;; | |
| *) | |
| echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment