[BACK]Return to mtctl_default.sh CVS log [TXT][DIR] Up to [local] / mtctl

Diff for /mtctl/mtctl_default.sh between version 1.8 and 1.9

version 1.8, 2022/12/06 15:34:44 version 1.9, 2023/05/02 18:04:20
Line 3 
Line 3 
 # Purpose: Minetest Server Control  # Purpose: Minetest Server Control
 # License: Copyright (C) 2021-2022 by Miniontoby <miniontoby@ircnow.org>  # License: Copyright (C) 2021-2022 by Miniontoby <miniontoby@ircnow.org>
 #---------------------------------------------------------------------  #---------------------------------------------------------------------
 VERSION="1.5"  VERSION="1.6"
 config=[]  config=[]
 config[0]="no"; config[1]="/usr/local/share/minetest/"  config[0]="no"; config[1]="/usr/local/share/minetest/"
   
Line 15  mtinfo() {
Line 15  mtinfo() {
         echo -e "mtctl: $MSG" | sed -e 's/\\n/\\nmtctl: /'          echo -e "mtctl: $MSG" | sed -e 's/\\n/\\nmtctl: /'
 }  }
 mthelp() {  mthelp() {
         echo -e "usage:  mtctl start|stop|restart|status|create|backup worldname\n        mtctl list|help|version|check_updates"          echo -e "usage:  mtctl start|stop|restart|status|create|backup|enable|disable worldname\n        mtctl list|help|version|check_updates"
 }  }
 if [ "x$1" == "x" ]; then mthelp; exit 0; fi  if [ "x$1" == "x" ]; then mthelp; exit 0; fi
   
Line 266  backupMT() {
Line 266  backupMT() {
         done          done
 }  }
   
   startupMT() {
           if [[ -f "$CONFDIR/startup" ]]; then
                   if [[ -f "$CONFDIR/.booted" ]]; then
                           exit 1
                   fi
                   failed=""
                   while read -r line
                   do
                           /usr/bin/mtctl start "$line" || failed="$failed, $line"
                   done < "$CONFDIR/startup"
                   if [[ "x$failed" == "x" ]]; then
                           echo "Success!"
                   else
                           echo "Servers have failed to start$failed"
                   fi
                   touch $CONFDIR/.booted
           fi
   }
   
   enableMT() {
           SetWorld "$1"
           if [[ -f "$CONFDIR/startup" ]]; then
                   INCLUDES=$(grep -x "$NAME" $CONFDIR/startup)
                   if [[ "X$INCLUDES" == "X$NAME" ]]; then
                           echo "$NAME is already enabled!"
                           return
                   fi
           fi
           if [[ $(crontab -l | egrep -v "^(#|$)" | grep -q '/usr/bin/mtctl startup'; echo $?) == 1 ]]; then
                   set -f
                   crontab -l > temp
                   echo '@reboot rm $HOME/.mtctl/.booted 2>/dev/null && /usr/bin/mtctl startup' >> temp
                   cat temp | crontab -
                   rm temp
                   set +f
           fi
           echo "$NAME" >> $CONFDIR/startup
           echo "$NAME is enabled!"
   }
   
   disableMT() {
           SetWorld "$1"
           if [[ -f "$CONFDIR/startup" ]]; then
                   INCLUDES=$(grep -x "$NAME" $CONFDIR/startup)
                   if [[ "X$INCLUDES" == "X$NAME" ]]; then
                           grep -xv "$NAME" $CONFDIR/startup > temp && mv temp $CONFDIR/startup
                           echo "$NAME is disabled!"
                           return
                   fi
           fi
           echo "$NAME is already disabled!"
   }
   
   
 #---------------------------------------------------------------------  #---------------------------------------------------------------------
 # Handle the actions  # Handle the actions
 ACTION="$1"  ACTION="$1"
Line 299  case $ACTION in
Line 352  case $ACTION in
         backup)          backup)
                 mtsetup                  mtsetup
                 backupMT "$2"                  backupMT "$2"
                   ;;
           startup)
                   startupMT
                   ;;
           enable)
                   #mtsetup
                   enableMT "$2"
                   ;;
           disable)
                   #mtsetup
                   disableMT "$2"
                 ;;                  ;;
         version)          version)
                 mtinfo "Version: $VERSION"                  mtinfo "Version: $VERSION"

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

CVSweb