Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Config
- . /etc/dmpserver/dmpserver.cfg
- # Lib
- . /var/lib/dmpserver/dmpbashlib
- # Check for root
- rootCheck
- start(){
- fileExistTest $DMPDIR/$1/DMPServer.exe
- if [ $RETVAL == "False" ] ; then
- echo "FATAL: COULD NOT LOCATE THE DMPSERVER ENVIRONMENT!"
- exit 2
- fi
- echo -n "Starting $SERVICENAME $1: "
- if [ ! -f $LOCKFILE.$1 ];
- then
- su $user -s $shell <<EOF
- screen -S $1 -d -m mono $DMPDIR/$1/DMPServer.exe
- EOF
- touch $LOCKFILE.$1
- echo -e "${formatDone} SUCCESS ${formatEnd}"
- else
- echo -e "${formatFail} FAILURE ${formatEnd}"
- echo "DMPSERVER IS ALREADY RUNNING, OR ROUGE LOCK FILE"
- exit 2
- fi
- }
- stop(){
- echo -n "Shutting down $SERVICENAME $1: "
- if [ -f $LOCKFILE.$1 ];
- then
- case "$2" in
- -f) dmpcmd $1 shutdown -f ;;
- *) dmpcmd $1 shutdown ;;
- esac
- rm -f $LOCKFILE.$1
- echo -e "${formatDone} SUCCESS ${formatEnd}"
- else
- echo -e "${formatFail} FAILURE ${formatEnd}"
- echo "DMPSERVER IS NOT RUNNING OR MISSING LOCK FILE"
- exit 2
- fi
- }
- restart(){
- echo -n "Restarting $SERVICENAME $1: "
- if [ -f $LOCKFILE.$1 ];
- then
- case "$2" in
- -f) dmpcmd $1 restart -f ;;
- *) dmpcmd $1 restart
- esac
- fi
- echo -e "${formatFail} DONE ${formatEnd}"
- }
- status(){
- echo -n "Status of $SERVICENAME $1: "
- if [ -f $LOCKFILE.$1 ];
- then
- echo -e "${formatDone} RUNNING ${formatEnd}"
- exit 1
- else
- echo -e "${formatFail} NOT RUNNING ${formatEnd}"
- exit 0
- fi
- }
- update(){
- dmpbashup
- }
- # Print usage if no arguments
- if [ $# -eq 0 ] ; then
- echo "Usage: $0 [server name] {start|stop|status|restart|stop-fast|restart-fast}"
- fi
- # Manipulate default server when only one arg is used
- if [ $# -eq 1 ] ; then
- case "$1" in
- start) start default ;;
- stop) stop default ;;
- stop-fast) stop default -f ;;
- restart) restart default ;;
- restart-fast) restart default -f ;;
- status) status default ;;
- update)
- update
- echo "Update successful! Please restart DMPServer for changes to take effect."
- ;;
- *)
- echo "Usage: $0 [server name] {start|stop|status|restart|stop-fast|restart-fast}"
- exit 3
- ;;
- esac
- fi
- # Otherwise, manipulate the named server
- if [ $# -eq 2 ] ; then
- case "$2" in
- start) start $1 ;;
- stop) stop $1 ;;
- stop-fast) stop $1 -f ;;
- status) status $1 ;;
- restart) restart $1 ;;
- restart-fast) restart $1 -f ;;
- update)
- update
- echo "Update successful! Please restart DMPServer for changes to take effect."
- ;;
- *)
- echo "Usage: $0 [server name] {start|stop|status|restart|stop-fast|restart-fast}"
- exit 3
- ;;
- esac
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement