Toto je starší verze dokumentu!
Startup script
brandonuv startup script je infinite loop:
while true do blabla done
proto bude lepsi udelat klasicky startup.sh s podminkama zda mtserver bezi, nic nedelat jinak zalohovat a cronem hlidat ten script
(17:24:24) Pitriss: Ritchie_: BTW v cronu se hodí ěnco ve stylu:
'' */5 * * * * minetest if [ `ps -e | grep -c minetestserver` = '0' ]; then /usr/local/bin/minetest_start.sh; fi ''
- minetest_start.sh
#!/bin/bash #This script is used to keep minetestserver running if it crash or stops. Also does backups and creates world map. ### config section # All patches to directories must have a slash "/" at end! #patch to world WORLD="/opt/minetest/world/classic_technic_game/" #patch to minetest directory MINETEST="/opt/minetest/" #patch to backup directory BACKUP="/opt/minetest-data/world-backups/" #patch to maps directory MAP_DIR="/opt/minetest-data/maps/" #patch to mapper directory MAPPER="/opt/minetest-git/minetest-mapper-cpp/" #path to directory with minetestserver logs LOGS="/opt/minetest-data/logs/" ### end of config section #variable which returns today's date and time in format for example 27102013_21:04:06 NOW="$(date +%d%m%Y_%T)" #name of world NAME="$(echo "$WORLD" | awk 'BEGIN { FS = "/" } {print $(NF-1)}')" #patch to minetest/world/ MT_WORLD="$(echo "$WORLD" | awk 'BEGIN { FS = "/"; OFS = "/" } {$(NF-1)=""; print$0}' | rev | cut -c2- | rev)" #patch and name of backup file BACKUP_TGZ="$BACKUP$NAME$NOW.tar.gz" #name of backup file TGZ="$NAME$NOW.tar.gz" #path and name of output map image MAP_OUT="$MAP_DIR$NAME$NOW.png" #name of output map image MAP="$NAME$NOW.png" #patch and name of logfile LOGFILE="$LOGS$NAME$NOW.txt" #debug of variables #echo WORLD $WORLD #echo MINETEST $MINETEST #echo BACKUP $BACKUP #echo MAP_DIR $MAP_DIR #echo MAPPER $MAPPER #echo LOGS $LOGS #echo NOW $NOW #echo NAME $NAME #echo MT_WORLD $MT_WORLD #echo BACKUP_TGZ $BACKUP_TGZ #echo TGZ $TGZ #echo MAP_OUT $MAP_OUT #echo MAP $MAP #echo LOGFILE $LOGFILE #backup of world to *tar.gz in backup directory cd $MT_WORLD ; tar cfz $BACKUP_TGZ $NAME ; cd - #symbolic link to $BACKUP$NAME-latest.tar.gz cd $BACKUP ; ln -sf $TGZ $NAME-latest.tar.gz ; cd - #check if mapper is ready if [ -x "$MAPPER/minetest_mapper" ] ; then #do a map $MAPPER/minetest_mapper -i $WORLD -o $MAP_OUT #symbolic link to $MAP_DIR$NAME-latest.png cd $MAP_DIR ; ln -sf $MAP $NAME-latest.png ; cd - else echo "minetest_mapper is not ready" fi #run minetestserver $MINETEST/bin/minetestserver &> $LOGFILE