Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #MonUpdate
- #Author: Nexon
- #Site: http://world4play.com/
- RETVAL=0
- COMMANDLINE_PARAMETERS="${2}"
- D1=$(readlink -f "$0")
- BINARYPATH="/var/www/html/cron/mon"
- USER="monupdate"
- cd "${BINARYPATH}"
- LIBRARYPATH="$(pwd)"
- BINARYNAME="update"
- case "$1" in
- start)
- if [ -e monupdate.pid ]; then
- echo "The MonUpdate is already running, try restart or stop"
- exit 7
- fi
- echo "Starting the MonUpdate..."
- if [ -e "$BINARYNAME" ]; then
- if [ ! -x "$BINARYNAME" ]; then
- echo "${BINARYNAME} is not executable, trying to set it"
- chmod u+x "${BINARYNAME}"
- fi
- if [ -x "$BINARYNAME" ]; then
- echo $! > monupdate.pid
- bash ./$BINARYNAME > /dev/null &
- echo "MonUpdate started!"
- else
- echo "${BINARNAME} is not exectuable, cannot start MonUpdate"
- fi
- else
- echo "Could not find binary, aborting"
- exit 5
- fi
- ;;
- stop)
- if [ -e monupdate.pid ]; then
- echo "Stopping the MonUpdate..."
- rm monupdate.pid
- echo "MonUpdate stoped!"
- exit 1
- else
- echo "MonUpdate not running"
- exit 7
- fi
- ;;
- restart)
- if [ -e monupdate.pid ]; then
- echo "Stopping the MonUpdate..."
- rm monupdate.pid
- echo "MonUpdate stoped!"
- else
- echo "MonUpdate not running"
- fi
- if [ -e monupdate.pid ]; then
- echo "The MonUpdate is already running, try restart or stop"
- exit 7
- fi
- echo "Starting the MonUpdate..."
- if [ -e "$BINARYNAME" ]; then
- if [ ! -x "$BINARYNAME" ]; then
- echo "${BINARYNAME} is not executable, trying to set it"
- chmod u+x "${BINARYNAME}"
- fi
- if [ -x "$BINARYNAME" ]; then
- echo $! > monupdate.pid
- bash ./$BINARYNAME > /dev/null &
- echo "MonUpdate started!"
- else
- echo "${BINARNAME} is not exectuable, cannot start MonUpdate"
- fi
- else
- echo "Could not find binary, aborting"
- exit 5
- fi
- ;;
- status)
- if [ -e monupdate.pid ]; then
- echo "MonUpdate is running"
- exit 1
- else
- echo "MonUpdate not running"
- exit 7
- fi
- ;;
- *)
- echo "Usage: service monupdate {start|stop|restart|status}"
- exit 2
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement