Advertisement
Guest User

TrackMania² servers - Failsafe cron script

a guest
Apr 26th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. logfile="/var/log/trackmania2/failsafe.log"
  4.  
  5. function checkIt()
  6. {
  7.  ps -fu tm2launcher | grep "$1" > /dev/null
  8.  
  9.  if [ $? != 0 ]
  10.  then
  11.    echo "[ERROR]$(date '+%Y-%m-%d %H:%M:%S'): TM2 $1 server not found, restarting it." >> $logfile;
  12.    if [ $1 == 'stadium' ]; then
  13.      /etc/init.d/trackmania2 restart >> $logfile
  14.    elif [ $1 == '\.rpg\.' ]; then
  15.      /etc/init.d/trackmania2_rpg restart >> $logfile
  16.    elif [ $1 == 'rpgbeg' ]; then
  17.      /etc/init.d/trackmania2_rpg restart beg >> $logfile
  18.    elif [ $1 == 'rpgint' ]; then
  19.      /etc/init.d/trackmania2_rpg restart int >> $logfile
  20.    elif [ $1 == 'rpgadv' ]; then
  21.      /etc/init.d/trackmania2_rpg restart adv >> $logfile
  22.    elif [ $1 == 'rpgexp' ]; then
  23.      /etc/init.d/trackmania2_rpg restart exp >> $logfile
  24.    elif [ $1 == 'rpgprv' ]; then
  25.      /etc/init.d/trackmania2_rpg restart prv >> $logfile
  26. #   elif [ $1 == 'ccpall' ]; then
  27. #     /etc/init.d/trackmania2_ccp restart all >> $logfile
  28. #   elif [ $1 == 'ccpesl' ]; then
  29. #     /etc/init.d/trackmania2_ccp restart esl >> $logfile
  30. #   elif [ $1 == 'ccpalp' ]; then
  31. #     /etc/init.d/trackmania2_ccp restart alp >> $logfile
  32.    fi;
  33.  
  34.  else
  35.    echo "[OK]$(date '+%Y-%m-%d %H:%M:%S'): TM2 $1 server still running." >> $logfile;
  36.  fi;
  37. }
  38.  
  39. checkIt "stadium";
  40. checkIt "\.rpg\.";
  41. checkIt "rpgbeg";
  42. checkIt "rpgint";
  43. checkIt "rpgadv";
  44. checkIt "rpgexp";
  45. checkIt "rpgprv";
  46. #checkIt "ccpall";
  47. #checkIt "ccpesl";
  48. #checkIt "ccpalp";
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement