[cod] Screen and su question.

Lance Shaw lshaw at rscs.net
Tue Jan 11 17:24:25 EST 2005


Hello everyone,

 

This is my first contribution to this list and I hope it is received well.

 

Although this does not answer your question directly, I would like to offer
this as one possible solution. Don't use screen. I am biased, as I
personally dislike the screen utility. That being said, I would like to
offer this BETA start script I have been working on. It is nothing special,
but it does make starting and stopping your COD servers pretty painless.

 

Please let me stress that A) This is a work in progress and your results may
vary from mine. B) Being that it is a work in progress, suggestions for
improvement are always very much welcome.

 

If you have your heart set on using screen, then I apologize for wasting
your time. :-)

 

-- BEGIN SCRIPT --

 

#!/bin/sh

 

# All paths should be absolute!

 

PID='Your PID file path here'

LOG='File path for console log here(/dev/null if you do not wish to capture
console output)'

COD='File path to program binary here'

IP='Server IP here'

PORT='Server Port here'

CONF='File path to config file here'

DED='Desired dedication level here'

ROOT='File path to your Data directory'

 

if [ $UID == 0 ]

then

echo "Cannot execute as root! su to appropriate user!"

exit 1

fi

 

cd $ROOT

 

case "$1" in

        start)

                echo "Starting Call of Duty Dedicated Server..."

                if [ -f $PID ]; then

                        echo "Server already running. Aborting start!"

                else

                        $COD +set dedicated $DED +set net_ip $IP +set
net_port $PORT +exec $CONF +map_rotate 1&>$LOG &

                        if [ $? == 0 ]; then

                                sleep 8 

                                echo $! >$PID

                                if [ -f $PID ]; then

                                        echo "Server started!"

                                else

                                        echo "WARNING: Could not create $PID
!"

                                        echo "Server started!"

                                fi

                        else

                                echo "Could not start server!"

                        fi

                fi

                ;;

        stop)

                echo "Stopping Call of Duty Dedicated Server..."

                if [ -f $PID ]; then

                        cat $PID | xargs kill

                        if [ $? == 0 ]; then

                                rm $PID

                                echo "Server stopped."

                        else

                                echo "Could not stop server!"

                        fi

                else

                        echo "Server not running!"

                fi

                ;;

        restart)

                echo "Restarting Call of Duty dedicated server..."

                if [ -f $PID ]; then

                        $0 stop

                        sleep 2

                        $0 start

                else

                        echo "Server not running!"

                        echo "Attempting to start..."

                        $0 start

                fi

                ;;

        *)

                echo "Usage: codds [ start | stop | restart ]"

                exit 1

esac

 

exit 0

 

-- END SCRIPT -

 

- Lance

  _____  

From: yuk [mailto:yuk at xs4all.nl] 
Sent: Tuesday, January 11, 2005 5:03 PM
To: cod at icculus.org
Subject: [cod] Screen and su question.

 

Hi Guys,

 

With great joy I have read all the posts in this lists and most of the
information is very valuable! Thank you all for that.

 

Now, the time has come that I need some help. 

 

I want to use screen to monitor my server and have created a script to start
it. However, I have a problem with screen which I do not know how to solve.
It's probably something trivial, but my UNIX knowledge is not so great yet
so I am quite stuck. Below is a snip let of what I wanted to do and does not
work.

 

 

Using username "yuk".

Authenticating with public key "imported-openssh-key" from agent

[yuk at yoda yuk]$ su -

Password:

[root at yoda root]# su - coduo -c screen

Cannot open your terminal '/dev/pts/6' - please check.

[root at yoda root]# ls -la /dev/pts

totaal 148

drwxr-xr-x   2 root root      0 jan 11  2005 .

drwxr-xr-x  25 root root 147456 jan 11 22:22 ..

crw--w----   1 cod  tty  136, 0 jan 11 22:58 0

crw--w----   1 yuk  tty  136, 1 jan 11 22:59 1

crw--w----   1 root tty  136, 2 jan 11 22:53 2

crw--w----   1 yuk  tty  136, 3 jan 11 22:59 3

crw-------   1 yuk  tty  136, 4 jan 11 22:59 4

crw--w----   1 yuk  tty  136, 5 jan 11 23:00 5

crw--w----   1 yuk  tty  136, 6 jan 11 23:00 6

[root at yoda root]# tty

/dev/pts/6

 

 

In bold, you can see that the screen command fails because it cannot open
the /dev/pts/6 pseudo terminal. That is correct because that terminal is
owned by the user YUK not the user CODUO which I have su'ed to before
calling screen.

 

If anyone can help me out I would really appreciate it.

 

Kind regards,

Yuk.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/cod/attachments/20050111/551d0ea4/attachment.htm>


More information about the Cod mailing list