Author Topic: Bash script to warn and save player chars before stop or restart  (Read 1599 times)

0 Members and 1 Guest are viewing this topic.

Offline poutch

  • Major(1)
  • Posts: 34
Bash script to warn and save player chars before stop or restart
« on: December 06, 2007, 12:58:01 pm »
Script Name: solstop
Script Description: Bash script to warn and save player chars before a reboot or stop of server
Original Author(s): Poutch
Code: [Select]
#! /bin/bash
# Author : Poutch (www.pleez.fr)
# This script was created to manage rpg style mod servers
# with a 1 minute warning before stop or reboot of server
# and a auto save of chars 10 seconds before shutdown
# Usage : ./solstop CMD IP PORT PASS
# CMD can be stop or restart
# in the script $SAVE is a command that will be executed 10 seconds before server reboot
# It should be used to save chars, and syntax depend on the soldat mod you are using

SAVE='/update'
SERVERPATH=$HOME'/soldatserver263/soldatserver -d'

case $# in
    4)

        CMD=$1
        IP=$2
        PORT=$3
        PASS=$4

        {
            echo $PASS
            echo '/say Server is going to reboot in 1 minute...'
            sleep 10
            for i in 50 40 30 20
              do
              echo "/say Server is going to reboot in $i sec..."
              sleep 10
            done
            echo $SAVE
            for ((i = 10; i > 0; i -= 1))
              do
              echo "/say Server rebooting in $i sec..."
              sleep 1
            done
            echo '/say Server rebooting NOW !'
            sleep 1
            echo 'SHUTDOWN'
        } | netcat $IP $PORT -w 1;

        if [ "$CMD" = "restart" ]
            then
            sleep 5
            $SERVERPATH
            echo 'Server Restarted'
        else
            echo 'Server Stopped'
        fi

        exit 1;

        ;;

    *)
        echo "usage : ./solstop CMD IP PORT ADMINPASS"
        echo "CMD can be stop or restart"

        exit 0;

        ;;

esac

For example i have a server that run a zombie mod with player getting experience, so i use this script to restart the server automaticcaly every 3 hours (with a crontab) and i'm sure that the players exp is saved before restart or shutdown.
« Last Edit: December 06, 2007, 01:04:18 pm by poutch »
www.pleez.fr .... coming soon

Offline pinOi32

  • Camper
  • ***
  • Posts: 339
  • "Bravo kid's bad day"
    • Newgrounds
Re: Bash script to warn and save player chars before stop or restart
« Reply #1 on: December 12, 2007, 04:53:05 pm »
what is your server??
Pls use my amazing interface:
http://forums.soldat.pl/index.php?topic=27584


I WIN!!

WHY MY KARMA SUCK??

Offline poutch

  • Major(1)
  • Posts: 34
Re: Bash script to warn and save player chars before stop or restart
« Reply #2 on: December 12, 2007, 09:10:51 pm »
i use that script on this server soldat://www.pleez.fr:23077

The mod script was made by danmer http://zm-mod.lemonserv.com/


-------

and also on {EF} public server CTF : soldat://www.pleez.fr:25011
« Last Edit: December 12, 2007, 09:18:44 pm by poutch »
www.pleez.fr .... coming soon