Help changing the color of the text output of start stop server.
Knight_Shield
Member Posts: 51
The text comes out grey in game . Kinda hard to see . I would like to change it to purple and maybe capitalize it.
#!/bin/bash
#nwservctl.sh
cd /home/nwn/.local/share/"Neverwinter Nights"/bin/linux-x86
#control command for nwn server, requires empty-expect
# **** BASIC CONFIGURATION ****
# Num of log directory to keep
LOG_HIST_NUM=9
# Seconds to wait for server loading
SECONDS_TO_WAIT=100
#Default Countdown in seconds
COUNTDOWN=60
# nwserver command: nwserver or nwnstartup.sh for NWNX2
#NWSERVER_COMMAND="nwnstartup.sh" #NWNX2
NWSERVER_COMMAND="nwserver-linux -module " #Basic nwserver
FIRST_EXIT_PHRASE="Restarting server in"
SECOND_EXIT_PHRASE="seconds please logout..."
# output passfrase to wait for module loaded
#PASS_PHRASE="0x08203e79" # NWNX2 init if you use nwnstartup.sh
PASS_PHRASE="Running..." # Basic nwserver
# **** END BASIC CONFIGURATION ****
# **** ADVANCED CONFIGURATION ******
# ONLY FOR EXPERTS
# start server command
NWSERVER_START="empty -f -i ./in.fifo -o ./out.fifo ./$NWSERVER_COMMAND"
# wait for loaded command
WAIT_LOADED="empty -w -t $SECONDS_TO_WAIT -i ./out.fifo -o ./in.fifo $PASS_PHRASE" # FOR nwnstartup.sh
# return output from server command
# use a timeout until all commands are debugged
CATCH_OUTPUT="empty -r -t 30 -b 8192 -i ./out.fifo"
# first line argument
ARG1="$1"
# exit code
EXCODE=0
# *** CODE ***
#check if arguments exist
if [ "x$ARG1" = "x" ] || [ "x$ARG1" = "xusage" ] || [ "x$ARG1" = "x--help" ]; then
echo "$Usage: `basename $0` start | restart [countdown [n]]" >&2
echo " `basename $0` stop [countdown [n]] | kill | status<div class="AlignLeft"></div>" >&2
echo " `basename $0` info [pid | pcpu | etime | pmem | vsz ] | --help" >&2
echo " `basename $0` <nwsever commands> if server is running" >&2
exit 1
fi
#nux check if nwserver is running exit if command is not
if [ "$(pidof nwserver-linux)" ] ; then
if [ "x$ARG1" = "xstart" ] ; then
echo "`basename $0` - nwserver already running..."
exit 1
else
: # do nothing continue
fi
else
if [ "x$ARG1" = "xstart" ] ; then
: # do nothing continue
else
echo "`basename $0` - nwserver is not running..."
exit 1
fi
fi
case $ARG1 in
start)
# rotate logs
[ -d ./logs ] || mkdir -p ./logs
if [ -d "./logs/logs.$LOG_HIST_NUM" ]; then
rm -f -r "./logs/logs.$LOG_HIST_NUM"
fi
for ((ddest=$LOG_HIST_NUM; ddest >= 2 ; ddest--)); do
let "dsourc = $ddest - 1"
if [ -d "./logs/logs.$dsourc" ]; then
mv -f "./logs/logs.$dsourc" "./logs/logs.$ddest"
fi
done
#move log.0 in log.1
mv -f ./logs.0 ./logs/logs.1
mkdir ./logs.0
#end rotate logs
shift
NWSERVER_START="$NWSERVER_START $*"
$NWSERVER_START
echo "Starting nwserver please wait.."
sleep 5
$WAIT_LOADED
if [ "$(pidof nwserver-linux)" ]
then
echo "nwserver is running now"
else
echo "nwserver loading failed.."
EXCODE=1
fi
;;
stop|restart)
if [ "x$2" = "xcountdown" ]; then
if [ "$3" -gt 0 ]; then
COUNTDOWN="$3"
fi
while [ "$COUNTDOWN" -gt 0 ]; do
$0 "say $FIRST_EXIT_PHRASE $COUNTDOWN $SECOND_EXIT_PHRASE"
let "COUNTDOWN -= 10"
sleep 10
done
fi
echo "exit" | empty -s -o ./in.fifo
$CATCH_OUTPUT
if [ "x$1" = "xrestart" ]; then
echo "restarting in 10 seconds please wait..."
sleep 10
$0 "start"
fi
;;
info)
case "$2" in
pcpu|etime|pmem|vsz)
ps -p "$(pidof nwserver-linux)" -o "$2="
;;
pid)
echo "$(pidof nwserver-linux)"
;;
*)
ps -p "$(pidof nwserver-linux)" -o pid,comm,etime,pmem,vsz,pcpu
;;
esac
;;
kill)
empty -k "$(pidof nwserver-linux)"
;;
# with return output
status|help|listbans)
echo "$ARG1" | empty -s -o ./in.fifo
$CATCH_OUTPUT
;;
# no return output
playerpassword|dmpassword|adminpassword|oneparty|ilr|elc|difficulty|servername|autosaveinterval|pauseandplay|minlevel|maxlevel|maxclients|export|kick)
echo "$*" | empty -s -o ./in.fifo
#no output to catch
;;
#all other commands default send to nwserver
*)
echo "$*" | empty -s -o ./in.fifo
$CATCH_OUTPUT
;;
esac
exit $EXCODE
0