I was wondering if I could appeal to you guys for some help with an init script
that involves 'screen'?
I will paste the script below. I believe the script works as designed, but my
'screen' may be misconfigured. Any attempts to run 'screen' results in the
error message that 'You are not the owner of /home/gure/tmp'. ('gure' being my
normal, non-root user account.)
This error causes screen (and thus any prog that it calls) to not run when
called from an init script (/etc/rc3.d/S99cs_source, which is a symlink to
/etc/init.d/counter_strike_source)
I would appreciate anybody's help in looking this over and offering what I can
do to properly configure screen and/or how to compensate within the script to
get it working. Ideally, I would want the screen session to be run as 'gure',
but I'll live with it if it can only be assigned to 'root'.
Any help is greatly appreciated. Thanks.
script begins below
-------------------
#!/bin/sh
# PATH TO THE GAME
GAME_PATH="/home/games/srcds_l"
# DEDICATED SERVER EXECUTEABLE
EXECUTEABLE="srcds_run"
#EXECUTEABLE="run_cs"
# COMMAND LINE OPTIONS FOR THE DEDICATED SERVER EXECUTEABLE
EXEC_OPTS="-game cstrike -port 27015 -autoupdate +ip 192.168.0.41"
# NAME FOR SCREEN
SCREEN_NAME="CSSOURCE"
############################################################
# #
# DO NOT EDIT BELOW THIS LINE #
# #
############################################################
running()
{
sleep 2
`pgrep -f "$SCREEN_NAME ./$EXECUTEABLE" > /dev/null`
if [ $? = 1 ]
then
echo -e "\t\t\t\033[00;31mnot running\033[0m"
else
echo -e "\t\t\t\033[00;32mrunning\033[0m"
fi
}
start()
{
echo -n "Starting $SCREEN_NAME dedicated server ... "
cd $GAME_PATH
`screen -A -m -d -S $SCREEN_NAME ./$EXECUTEABLE $EXEC_OPTS`
# `sudo -u gure screen -A -m -d -S $SCREEN_NAME ./$EXECUTEABLE $EXEC_OPTS`
}
stop()
{
echo -n "Shutting down $SCREEN_NAME dedicated server ... "
`kill -9 "$SCREEN_NAME"`
}
case $1 in
start)
start
running
;;
stop)
stop
running
;;
restart)
stop
running
start
running
;;
status)
echo -n "$SCREEN_NAME dedicated server is ... "
running
;;
*)
echo "Usage: $0 ( start | stop | restart | status )"
exit 1
;;
esac
exit 0