I modified the default script to run the server under a special user account and added some variablels.
This runs in a Suse Linux 8.1 environment
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#!/bin/bash
#
# ofpserver: Operation Flashpoint Linux dedicated server control script
# Â (c) 2003 BIStudio
#
# with modifications done by Lamorak
#
# Â OFP binary version must be 1.92 or later!
. /etc/rc.status
#=======================================================================
#======== Â Â Â Â Â Â Â CONFIGURATION PARAMETERS Â Â Â Â Â Â Â Â ========
#======== MUST BE EDITED MANUALLY TO FIT YOUR SYSTEM PARAMETERS ========
#=======================================================================
MYDATE=$(date +%y-%m-%d)
OFP_USER=ofpserver
OFP_DIR=/home/ofpserver/ofp
CONFIG=${OFP_DIR}/server.cfg
PORT=2302
PIDFILE=${OFP_DIR}/ofp_server.${PORT}.pid
RUNFILE=${OFP_DIR}/ofp.server.${PORT}.run
LOGFILE=${OFP_DIR}/logs/${MYDATE}_${PORT}.log
SERVER=${OFP_DIR}/server
#=======================================================================
return=$rc_done
case "$1" in
  start)
if [ -f ${RUNFILE} ]; then
  $0 stop
fi
echo -n "Starting OFP server..."
# file to mark we want server running...
su $OFP_USER -c "echo \"go\" >${RUNFILE}"
# launch the background watchdog process to run the server
nohup </dev/null >/dev/null $0 watchdog &
echo -e "$return"
;;
  stop)
echo -n "Stopping OFP server..."
if [ -f ${RUNFILE} ]; then
# ask watcher process to exit by deleting its runfile...
  su $OFP_USER -c "rm -f ${RUNFILE}"
fi
# and terminate OFP server process
if [ -f ${PIDFILE} ]; then
  su $OFP_USER -c "kill -TERM $(< ${PIDFILE})" || return=$rc_failed
  if [ -f ${PIDFILE} ]; then
su $OFP_USER -c "rm -f ${PIDFILE}"
  fi
fi
echo -e "$return"
;;
  status)
if [ -f ${RUNFILE} ]; then
  echo "Server should be running..."
else
  echo "Server should not be running..."
fi
if [ -f ${PIDFILE} ]; then
  PID=$(< ${PIDFILE})
  echo "PID file exists (PID=${PID})..."
  if [ -f /proc/${PID}/cmdline ]; then
echo "Server process seems to be running..."
  fi
fi
;;
  check)
echo -n "OFP directory: ${OFP_DIR} "
if [ -d ${OFP_DIR} ]; then
  echo "OK"
else
  echo "MISSING!"
fi
echo -n "Server executable: ${SERVER} "
if [ -x ${SERVER} ]; then
  echo "OK"
else
  echo "ERROR!"
fi
echo "Port number: ${PORT}"
echo -n "Config file: ${CONFIG} "
if [ -f ${CONFIG} ]; then
  echo "OK"
else
  echo "MISSING!"
fi
echo "PID file: ${PIDFILE}"
echo "RUN file: ${RUNFILE}"
;;
  restart)
$0 stop && $0 start || return=$rc_failed
    ;;
  watchdog)
# this is a background watchdog process. Do not start directly
while [ -f ${RUNFILE} ]; do
# launch the server...
  cd ${OFP_DIR}
  su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Starting server (port ${PORT})...\""
  su $OFP_USER -c "${SERVER} >>${LOGFILE} 2>&1 -server -nomap -config=${CONFIG} -port=${PORT} -pid=${PIDFILE}" || return=$rc_failed
  if [ -f ${RUNFILE} ]; then
su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Server died, waiting to restart...\""
sleep 5s
  else
su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Server shutdown intentional, watchdog terminating\""
  fi
done
;;
  *)
echo "$0 (start|stop|restart|status|check)"
;;
esac
To execute at boottime, the script is palced in /etc/init.d with a reference in /etc/init.d/rc3.d
Some users are allowed to execute this script with the following aliases:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">alias ofpstart='sudo /etc/init.d/ofpserver start'
alias ofpstop='sudo /etc/init.d/ofpserver stop'
Do be allowed to use "sudo" on /etc/init.d/ofpserver the file /etc/sudoers has to be modified. I added the following line for every user who should be able to restart the server:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"><username> Â ALL = NOPASSWD: /etc/init.d/ofpserver
No matter who operates the server it is always running unter the "ofpserver" account.
Perhaps this can be usefull.
One thing I am missing: As long as the server runs, his otuput goes to the same logfile for days. Is it possible to change to an other logile without restarting the server?
One more ;) :
I don't use modfolders for the server yet, but this could be implementet very easy, I think:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">watchdog)
# this is a background watchdog process. Do not start directly
while [ -f ${RUNFILE} ]; do
# launch the server...
  cd ${OFP_DIR}
  su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Starting server (port ${PORT})...\""
# begin modfolders
case "$2" in
config1)
  su $OFP_USER -c "${SERVER} >>${LOGFILE} 2>&1 -server -nomap -mod= .... -config=${CONFIG} -port=${PORT} -pid=${PIDFILE}" || return=$rc_failed
;;
config2)
...
;;
esac
#end modfolder
 if [ -f ${RUNFILE} ]; then
su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Server died, waiting to restart...\""
sleep 5s
  else
su $OFP_USER -c "echo >>${LOGFILE} \"WATCHDOG ($$): [$(date)] Server shutdown intentional, watchdog terminating\""
  fi
done
;;
It would be startet with "etc/init.d/ofpserver start config1". Not testet, but should work