Find the answer to your Linux question:
Results 1 to 2 of 2
I am writing my first bash script start and stop my Call of Duty 2 Linux server. I am just about done but whenever I run the script it gives ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    5

    Question Problem with init-functions?

    I am writing my first bash script start and stop my Call of Duty 2 Linux server. I am just about done but whenever I run the script it gives me the following error:

    Code:
    open: Permission denied
     * Starting Call of Duty 2 Dedicated Server: cod2_lnxded
    open: Permission denied
    If I look at the process list, I can see that the sever starts. When I go to stop it, it stops, gives the same sort of error, and doesn't remove the pid file like it should. I can't seem to figure out why it does this. I think it has something to do with the init-functions I am using because when I started to use them, the problem started. I am using Ubuntu 7.04 as my distro. The script is posted below.

    Code:
    #!/bin/bash
    
    APP_PATH=/home/cod/cod2
    PID_FILE=cod2.pid
    RCON_PASS=password
    
    if [ -r /lib/lsb/init-functions ]; then
    	. /lib/lsb/init-functions
    	LOG_BEGIN="log_begin_msg"
    	LOG_END="log_end_msg"
    else
    	LOG_BEGIN="echo -n"
    	LOG_END=`printf "echo .\n"`
    fi
    
    # Exit if the daemon binary is NOT available, executable, etc.
    test -x $APP_PATH/cod2_lnxded || exit 0
    
    start() {
    	$LOG_BEGIN "Starting Call of Duty 2 Dedicated Server: cod2_lnxded"
    	start-stop-daemon --start --pidfile $PID_FILE --make-pidfile $PID_FILE \
    		--chdir $APP_PATH --background --exec ./cod2_lnxded \
    		+exec dedicated.cfg +map_rotate +set rcon_password $RCON_PASS
    	$LOG_END $?
    }
    
    stop() {
    	$LOG_BEGIN "Stopping Call of Duty 2 Dedicated Server: cod2_lnxded"
    	start-stop-daemon --stop --pidfile $PID_FILE --chdir $APP_PATH
    	$LOG_END $?
    }
    
    status() {
    	if [ -e $PID_FILE ]; then
    		echo "The Call of Duty 2 server is running with a PID of `cat $PID_FILE`"
    	else
    		echo "The Call of Duty 2 server is not running"
    	fi
    }
    
    case "$1" in
    	start)
    		start
    		;;
    	stop)
    		stop
    		;;
    	restart)
    		stop
    		sleep 1
    		start
    		;;
    	status)
    		status
    		;;
    	*)
            	log_success_msg "Usage: callofduty2-server-launcher {start|stop|reload|status}"
            	exit 1
            	;;
    esac
    exit 0

  2. #2
    Just Joined!
    Join Date
    Jun 2007
    Posts
    5
    *bump*

    Any help would be greatly appreciated. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...