Kugane

[Linux] Restart Script for ExileMod

37 posts in this topic

I made a restart script for the Exile Mod internal restart function.

It looks into your logfile & if it found the "Exile Server: "SERVER READY FOR RESTART!!!" then,

it move your old logfile in a new folder sorted by YEAR/MONTH/DAY & rename the old logfile to log_HOUR/MINUTE. 

 

Tested on Ubuntu 14.04 LTS x64

#!/bin/bash
# Made by Kugane
# tcc-clan.de
 
####################################################################
### Logfiles
####################################################################
 
logfile="log"               #name of your logfile
 
file_extension=".rpt"       #file extension of your logfiles, can be .rpt, .log, .txt
 
####################################################################
### Directory's
####################################################################
 
logdir="logs"                       #name of your logfile folder, recommended for a better overview!
serverdir="serverfiles"             #location of your serverfiles
 
executable="arma3server restart"     #name of your serverscript
executabledir="home/steam"           #location of your server script
 
 
####################################################################
### Do not edit!!!
####################################################################
stored_logfile="$logfile"_"$(date '+%H-%M-%S')$file_extension"
stored_logdir="$logdir/$(date +%Y)/$(date +%m)/$(date +%d)"
 
if [[ ! -f /$executabledir/$serverdir/$logdir/$logfile$file_extension ]]; then
    clear
    echo "No $logfile$file_extension found!"
    echo ""
    echo "==========Debug=========="
    echo ""                                                                    
    echo "Your log should be in:    /$executabledir/$serverdir/$logdir/$logfile$file_extension"  
    echo ""                                                                    
    echo "Your executable should be in:     /$executabledir/$executable"
    echo ""    
exit;
    else if
    clear
    [ "$(grep 'READY FOR RESTART' /$executabledir/$serverdir/$logdir/$logfile$file_extension)" ]; then
   
        echo "Create Directory for old Logfiles = $stored_logdir"
            cd /$executabledir/$serverdir && mkdir -p $stored_logdir
            sleep 2
        echo "Move old Logfile in $stored_logdir"
            mv /$executabledir/$serverdir/$logdir/$logfile$file_extension /$executabledir/$serverdir/$stored_logdir/$stored_logfile
            sleep 2
        echo "Restart Server"
            cd /$executabledir && ./$executable
        echo "Server Restart should be done...!"
    else
        echo "No Restart required"
    exit;
    fi
fi

 

crontab for automation   

*/1 * * * *   sh /home/steam/arma3restart.sh

 

 

here is a pastebin link for easy copy [Linux] Restart Script for ExileMod 

 

I use it with LGSM arma3server: ARMA 3 Linux Server Manger

edit in "arma3server" (from LGSM the line 

57 ./arma3server >>${systemdir}/logs/log.rpt 2>&1

 

If you have any questions, ask me! 

Edited by Kugane
Updated the script for better log reading, & added the start script that i'm used (@xunin enjoy it!)
  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

Unfortunately this script doesnt want to read busy log files on my ubuntu server. 

I use https://github.com/dgibbs64/linuxgsm and crontab with restart command every 3 h. 

And php scripts to announce restarts.

https://github.com/deannreid/BattlEye-RCON-Control-PHP/tree/master/Restart Warnings

 

thx 4 the hint!, i have only logfiles à 100mb & these works fine.

i updated the script & now it works with a max. filesize at 3.4gb on 32bit distribution & a lot more on 64bit distro's

 

 

Edited by Kugane

Share this post


Link to post
Share on other sites

If you want restart every 6hrs you can use crontab -e

0 0,6,12,18 * * * /home/exile2esseker/arma3server/serverfiles/./script.sh restart

and the script i use

armaserver: ArmA 3 Linux Dedicated Server Control Script

http://pastebin.com/Zq0kt0xS

The nice thong about it it clears logs once every week and keep the server going

 

Edited by Khazaztroph
Mister typo :/

Share this post


Link to post
Share on other sites

Try to make this work since 2 day .... but can't :(

maybe somebody can help me to find were i fail :o


/home/arma3    Arma 3 Server Folder

/home/arma3/reboot.sh --> This one

crontab -e --> 0 0,6,12,18 * * * /home/arma3/./reboot.sh restart

config.cfg and basic.cfg --> /home/arma3/cfg

battleye --> /home/arma3/battleye

Anybody find whats wrong ?

Edited by nark0t1k

Share this post


Link to post
Share on other sites

did you enter your server file and config details in reboot.sh?

Did u do chmod +x reboot.sh?

 /home/arma3/./reboot.sh why there is a dot between arma3 and reboot.sh?

Edited by WD-40

Share this post


Link to post
Share on other sites

 

Try to make this work since 2 day .... but can't :(

maybe somebody can help me to find were i fail :o


/home/arma3    Arma 3 Server Folder

/home/arma3/reboot.sh --> This one

crontab -e --> 0 0,6,12,18 * * * /home/arma3/./reboot.sh restart

config.cfg and basic.cfg --> /home/arma3/cfg

battleye --> /home/arma3/battleye

Anybody find whats wrong ?

can you link the source script ?

or test your script is right edited with, ./reboot.sh check

 

did you enter your server file and config details in reboot.sh?

Did u do chmod +x reboot.sh?

 /home/arma3/./reboot.sh why there is a dot between arma3 and reboot.sh?

this is the crontab, but i don't know if the syntax correct.

I would make it so

0 */6 * * * sh /home/arma3/reboot.sh restart

 

Edited by Kugane

Share this post


Link to post
Share on other sites

Personally I use LGSM, once set up correctly all you have to do is "arma3server restart", that is, if you use the default script name. If your configs are right the server will warn, autolock and then kick all, right before your cron job "0 */3 * * * /home/arma/arma3server restart" fires and restarts the server.

Edited by Crazy Harry

Share this post


Link to post
Share on other sites

LGSM is nice if you are new to linux and want a easy setup. you can still use the bin/bash script.

If you read at the bottom you have following commands you can use with the script to check if everything is working or if the server is on.

start | stop | restart | status | check | log

so run the sh file like ./script.sh check

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.