7 NWSERVER_SAVE_NAME
=shutdown
8 NWSERVER_SAVE_TIMEOUT
=10
11 .
/etc
/conf.d
/nwserver
13 _daemonName
="Neverwinter Nights server"
14 _logDir
="/var/log/nwserver"
15 _runDir
="/var/run/nwserver"
17 _expectScript
=$
(cat << EOS
18 set timeout "$NWSERVER_SAVE_TIMEOUT"
22 expect "Server: Exiting..." {return 0}
26 spawn attachtty "$_runDir/socket"
27 send "forcesave $NWSERVER_SAVE_SLOT $NWSERVER_SAVE_NAME\r"
29 "Server: Save complete" {
41 stat_busy
"Starting $_daemonName"
42 if [[ ! -f "$_runDir/server.pid" ]]; then
43 if [[ ! -d "$_runDir" ]]; then
45 chown nwserver
:nwserver
"$_runDir"
47 su nwserver
-c "RW_BRANCH=$_srvDir detachtty --dribble-file $_logDir/server_stdout.log --log-file $_logDir/detachtty.log --pid-file $_runDir/server.pid $_runDir/socket /usr/bin/nwserver $NWSERVER_ARGS -interactive" &&
48 add_daemon nwserver
&&
49 stat_done || stat_fail
55 stat_busy
"Stopping $_daemonName"
56 if [[ ! -f "$_runDir/server.pid" ]]; then
61 if [[ -S "$_runDir/socket" ]]; then
62 echo "$_expectScript" | expect
- &> /dev
/null
&&
66 # nwserver didn't stop
81 stat_busy
"Checking $_daemonName status"
85 echo "usage: $0 {start|stop|restart|status}"