Paste Code
Paste Blends
Paste Images
This is start_mt.sh:

#! /bin/bash

readonly LOCKFILE_DIR=.
readonly LOCKFILE=$LOCKFILE_DIR/minetest_db.lock
readonly LOCK_FD=231

lock() {
eval "exec $LOCK_FD>$LOCKFILE"

flock -n $LOCK_FD && return 0 || return 1
}

endlock() {
rm -f $LOCKFILE
}

while [ 1 ]; do
while [ lock() ]; do
sleep 1
done
/home/billys/minetest/bin/minetestserver --config ~/.minetest/worlds/blocky_survival/config.conf --logfile /home/billys/mtlog.txt --worldname blocky_survival
endlock()
sleep 0.5
done







This is backup_mt.sh:

#! /bin/bash

readonly LOCKFILE_DIR=.
readonly LOCKFILE=$LOCKFILE_DIR/minetest_db.lock
readonly LOCK_FD=231

lock() {
eval "exec $LOCK_FD>$LOCKFILE"

flock -n $LOCK_FD && return 0 || return 1
}

endlock() {
rm -f $LOCKFILE
}

MT_PID=$(pgrep -a minetestserver | grep /home/billys/minetest/bin/minetestserver | awk '{print $1}')
kill $MT_PID

lock()
cp /home/billys/.minetest/worlds/blocky_survival /tmp/blocky_survival
endlock()
tar -zcvf /home/billys/backup.tar.gz /tmp/blocky_survival
rm -rf /tmp/blocky_survival
  1. This is start_mt.sh:
  2.  
  3. #! /bin/bash
  4.  
  5. readonly LOCKFILE_DIR=.
  6. readonly LOCKFILE=$LOCKFILE_DIR/minetest_db.lock
  7. readonly LOCK_FD=231
  8.  
  9. lock() {
  10.         eval "exec $LOCK_FD>$LOCKFILE"
  11.  
  12.         flock -n $LOCK_FD && return 0 || return 1
  13. }
  14.  
  15. endlock() {
  16.         rm -f $LOCKFILE
  17. }
  18.  
  19. while [ 1 ]; do
  20.         while [ lock() ]; do
  21.                 sleep 1
  22.         done
  23.         /home/billys/minetest/bin/minetestserver --config ~/.minetest/worlds/blocky_survival/config.conf --logfile /home/billys/mtlog.txt --worldname blocky_survival
  24.         endlock()
  25.         sleep 0.5
  26. done
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. This is backup_mt.sh:
  35.  
  36. #! /bin/bash
  37.  
  38. readonly LOCKFILE_DIR=.
  39. readonly LOCKFILE=$LOCKFILE_DIR/minetest_db.lock
  40. readonly LOCK_FD=231
  41.  
  42. lock() {
  43.         eval "exec $LOCK_FD>$LOCKFILE"
  44.  
  45.         flock -n $LOCK_FD && return 0 || return 1
  46. }
  47.  
  48. endlock() {
  49.         rm -f $LOCKFILE
  50. }
  51.  
  52. MT_PID=$(pgrep -a minetestserver | grep /home/billys/minetest/bin/minetestserver | awk '{print $1}')
  53. kill $MT_PID
  54.  
  55. lock()
  56. cp /home/billys/.minetest/worlds/blocky_survival /tmp/blocky_survival
  57. endlock()
  58. tar -zcvf /home/billys/backup.tar.gz /tmp/blocky_survival
  59. rm -rf /tmp/blocky_survival
go to heaven