Advertisement
Guest User

W4PMon

a guest
Aug 4th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.17 KB | None | 0 0
  1. #!/bin/sh
  2. #MonUpdate
  3. #Author: Nexon
  4. #Site: http://world4play.com/            
  5.  
  6. RETVAL=0
  7. COMMANDLINE_PARAMETERS="${2}"
  8. D1=$(readlink -f "$0")
  9. BINARYPATH="/var/www/html/cron/mon"                                                                              
  10. USER="monupdate"
  11. cd "${BINARYPATH}"
  12. LIBRARYPATH="$(pwd)"
  13. BINARYNAME="update"
  14.  
  15. case "$1" in
  16.     start)
  17.         if [ -e monupdate.pid ]; then
  18.                 echo "The MonUpdate is already running, try restart or stop"
  19.                 exit 7
  20.         fi
  21.         echo "Starting the MonUpdate..."
  22.         if [ -e "$BINARYNAME" ]; then
  23.             if [ ! -x "$BINARYNAME" ]; then
  24.                 echo "${BINARYNAME} is not executable, trying to set it"
  25.                 chmod u+x "${BINARYNAME}"
  26.             fi
  27.             if [ -x "$BINARYNAME" ]; then
  28.                 echo $! > monupdate.pid
  29.                 bash ./$BINARYNAME > /dev/null &
  30.                 echo "MonUpdate started!"
  31.             else
  32.                 echo "${BINARNAME} is not exectuable, cannot start MonUpdate"
  33.             fi
  34.         else
  35.             echo "Could not find binary, aborting"
  36.             exit 5
  37.         fi
  38.     ;;
  39.     stop)
  40.         if [ -e monupdate.pid ]; then
  41.             echo "Stopping the MonUpdate..."
  42.             rm monupdate.pid
  43.             echo "MonUpdate stoped!"
  44.             exit 1
  45.         else
  46.             echo "MonUpdate not running"
  47.             exit 7
  48.         fi
  49.     ;;
  50.     restart)
  51.         if [ -e monupdate.pid ]; then
  52.             echo "Stopping the MonUpdate..."
  53.             rm monupdate.pid
  54.             echo "MonUpdate stoped!"
  55.         else
  56.             echo "MonUpdate not running"
  57.         fi
  58.         if [ -e monupdate.pid ]; then
  59.                 echo "The MonUpdate is already running, try restart or stop"
  60.                 exit 7
  61.         fi
  62.  
  63.         echo "Starting the MonUpdate..."
  64.         if [ -e "$BINARYNAME" ]; then
  65.             if [ ! -x "$BINARYNAME" ]; then
  66.                 echo "${BINARYNAME} is not executable, trying to set it"
  67.                 chmod u+x "${BINARYNAME}"
  68.             fi
  69.             if [ -x "$BINARYNAME" ]; then      
  70.                 echo $! > monupdate.pid    
  71.                 bash ./$BINARYNAME > /dev/null &
  72.                 echo "MonUpdate started!"
  73.             else
  74.                 echo "${BINARNAME} is not exectuable, cannot start MonUpdate"
  75.             fi
  76.         else
  77.             echo "Could not find binary, aborting"
  78.             exit 5
  79.         fi
  80.     ;;
  81.     status)
  82.         if [ -e monupdate.pid ]; then
  83.             echo "MonUpdate is running"
  84.             exit 1
  85.         else
  86.             echo "MonUpdate not running"
  87.             exit 7
  88.         fi
  89.     ;;
  90.     *)
  91.         echo "Usage: service monupdate {start|stop|restart|status}"
  92.         exit 2
  93. esac
  94. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement