source: scripts/usr/local/bin/7dtd-kill.sh @ 14

Last change on this file since 14 was 14, checked in by alloc, 9 years ago

More instance validation, switch to XMLStarlet, config.xml instead of serverconfig.xml, admins.xml instead of serveradmin.xml

  • Property svn:executable set to *
File size: 839 bytes
Line 
1#!/bin/bash
2# Version 3
3
4# Tries to stop the 7dtd instance given as first parameter.
5# Returns:
6#  0 : Done
7#  1 : Was not running
8#  2 : No instance name given
9#  3 : No such instance
10
11. /usr/local/bin/7dtd-common.sh
12checkRootLoadConf
13
14checkInstanceValid $1
15
16res=$(isRunning $1)
17if [ $res -eq 1 ]; then
18        echo "Trying to gracefully shutdown..."
19        tmp=$(telnetCommand $1 shutdown)
20        echo "Waiting for server to shut down..."
21       
22        waittime=0
23        maxwait=5
24        until [ $(isRunning $1) -eq 0 ] || [ $waittime -eq $maxwait ]; do
25                (( waittime++ ))
26                sleep 1
27                echo $waittime/$maxwait
28        done
29       
30        if [ $(isRunning $1) -eq 1 ]; then
31                echo "Failed, force closing server..."
32                start-stop-daemon --stop --pidfile $(getInstancePath $1)/7dtd.pid
33        fi
34        rm $(getInstancePath $1)/7dtd.pid
35        echo "Done"     
36        exit 0
37else
38        echo "7dtd instance $1 is NOT running"
39        exit 1
40fi
Note: See TracBrowser for help on using the repository browser.