mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			102 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/bash
 | |
| #
 | |
| # vmops		Script to start and stop the VMOps Agent.
 | |
| #
 | |
| # Author:       Chiradeep Vittal <chiradeep@vmops.com>
 | |
| # chkconfig: 2345 99 01
 | |
| # description: 	Start up the VMOps agent
 | |
| 
 | |
| # Source function library.
 | |
| if [ -f /etc/init.d/functions ]
 | |
| then
 | |
|   . /etc/init.d/functions
 | |
| fi
 | |
| 
 | |
| _success() {
 | |
|   if [ -f /etc/init.d/functions ]
 | |
|   then
 | |
|     success
 | |
|   else
 | |
|     echo "Success"
 | |
|   fi
 | |
| }
 | |
| 
 | |
| _failure() {
 | |
|   if [ -f /etc/init.d/functions ]
 | |
|   then
 | |
|     failure
 | |
|   else
 | |
|     echo "Failed"
 | |
|   fi
 | |
| }
 | |
| RETVAL=$?
 | |
| VMOPS_HOME="/usr/local/vmops"
 | |
| 
 | |
| mkdir -p /var/log/vmops
 | |
| 
 | |
| get_pids() {
 | |
|   local i
 | |
|   for i in $(ps -ef| grep java | grep -v grep | awk '{print $2}'); 
 | |
|   do 
 | |
|     echo $(pwdx $i) | grep "$VMOPS_HOME" | grep -i console | awk -F: '{print $1}'; 
 | |
|   done
 | |
| }
 | |
| 
 | |
| start() {
 | |
|    local pid=$(get_pids)
 | |
|    echo -n "Starting VMOps Console Proxy: "
 | |
|    if [ -f $VMOPS_HOME/consoleproxy/run.sh ];
 | |
|    then
 | |
|      if [ "$pid" == "" ]
 | |
|      then
 | |
|        (cd $VMOPS_HOME/consoleproxy; nohup ./run.sh > /var/log/vmops/vmops.out 2>&1 & )
 | |
|        pid=$(get_pids)
 | |
|        echo $pid > /var/run/vmops.pid 
 | |
|      fi
 | |
|      _success
 | |
|    else
 | |
|      _failure
 | |
|    fi
 | |
|    echo
 | |
| }
 | |
| 
 | |
| stop() {
 | |
|   local pid
 | |
|   echo -n  "Stopping VMOps agent: "
 | |
|   for pid in $(get_pids)
 | |
|   do
 | |
|     kill $pid
 | |
|   done
 | |
|   _success
 | |
|   echo
 | |
| }
 | |
| 
 | |
| status() {
 | |
|   local pids=$(get_pids)
 | |
|   if [ "$pids" == "" ]
 | |
|   then
 | |
|     echo "VMOps agent is not running"
 | |
|     return 1
 | |
|   fi
 | |
|   echo "VMOps agent is running: process id: $pids"
 | |
|   return 0
 | |
| }
 | |
| 
 | |
| 
 | |
| case "$1" in
 | |
|    start) start
 | |
| 	  ;;
 | |
|     stop) stop
 | |
|  	  ;;
 | |
|     status) status
 | |
|  	  ;;
 | |
|  restart) stop
 | |
|           start
 | |
|  	  ;;
 | |
|        *) echo $"Usage: $0 {start|stop|status|restart}"
 | |
| 	  exit 1
 | |
| 	  ;;
 | |
| esac
 | |
| 
 | |
| exit $RETVAL
 |