| 
									
										
										
										
											2015-07-23 14:53:37 -04:00
										 |  |  | ### BEGIN INIT INFO | 
					
						
							|  |  |  | # Provides:          poller-service | 
					
						
							|  |  |  | # Required-Start:    networking | 
					
						
							|  |  |  | # Required-Stop:     networking | 
					
						
							|  |  |  | # Default-Start:     2 3 4 5 | 
					
						
							|  |  |  | # Default-Stop:      0 1 6 | 
					
						
							|  |  |  | # Short-Description: The LibreNMS poller-service daemon | 
					
						
							|  |  |  | # Description:       The LibreNMS poller-service daemon | 
					
						
							|  |  |  | #                    This polls devices monitored by LibreNMS | 
					
						
							|  |  |  | ### END INIT INFO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 14:59:17 -04:00
										 |  |  | . /lib/lsb/init-functions | 
					
						
							| 
									
										
										
										
											2015-07-23 14:53:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | NAME=poller-service | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DAEMON=/opt/librenms/poller-service.py | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 15:03:01 -04:00
										 |  |  | USER=librenms | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 14:53:37 -04:00
										 |  |  | PIDFILE=/var/run/poller-service.pid | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test -x $DAEMON || exit 5 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | case $1 in | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  start) | 
					
						
							|  |  |  |   # Checked the PID file exists and check the actual status of process | 
					
						
							|  |  |  |   if [ -e $PIDFILE ]; then | 
					
						
							|  |  |  |    status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?" | 
					
						
							|  |  |  |    # If the status is SUCCESS then don't need to start again. | 
					
						
							|  |  |  |    if [ $status = "0" ]; then | 
					
						
							|  |  |  |     exit # Exit | 
					
						
							|  |  |  |    fi | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   # Start the daemon. | 
					
						
							|  |  |  |   log_daemon_msg "Starting the process" "$NAME" | 
					
						
							|  |  |  |   # Start the daemon with the help of start-stop-daemon | 
					
						
							|  |  |  |   # Log the message appropriately | 
					
						
							| 
									
										
										
										
											2015-07-23 15:09:06 -04:00
										 |  |  |   if start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background; then | 
					
						
							| 
									
										
										
										
											2015-07-23 14:53:37 -04:00
										 |  |  |    log_end_msg 0 | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |    log_end_msg 1 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   ;; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  stop) | 
					
						
							|  |  |  |   # Stop the daemon. | 
					
						
							|  |  |  |   if [ -e $PIDFILE ]; then | 
					
						
							|  |  |  |    status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?" | 
					
						
							|  |  |  |    if [ "$status" = 0 ]; then | 
					
						
							| 
									
										
										
										
											2015-07-23 15:10:59 -04:00
										 |  |  |     start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE | 
					
						
							| 
									
										
										
										
											2015-07-23 14:53:37 -04:00
										 |  |  |     /bin/rm -rf $PIDFILE | 
					
						
							|  |  |  |    fi | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |    log_daemon_msg "$NAME process is not running" | 
					
						
							|  |  |  |    log_end_msg 0 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   ;; | 
					
						
							|  |  |  |  restart) | 
					
						
							|  |  |  |   # Restart the daemon. | 
					
						
							|  |  |  |   $0 stop && sleep 2 && $0 start | 
					
						
							|  |  |  |   ;; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  status) | 
					
						
							|  |  |  |   # Check the status of the process. | 
					
						
							|  |  |  |   if [ -e $PIDFILE ]; then | 
					
						
							|  |  |  |    status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $? | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |    log_daemon_msg "$NAME Process is not running" | 
					
						
							|  |  |  |    log_end_msg 0 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   ;; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  *) | 
					
						
							|  |  |  |   # For invalid arguments, print the usage message. | 
					
						
							|  |  |  |   echo "Usage: $0 {start|stop|restart|reload|status}" | 
					
						
							|  |  |  |   exit 2 | 
					
						
							|  |  |  |   ;; | 
					
						
							|  |  |  | esac |