Rozdíly
Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.
dev:scripty:startup_script [28.10.2013 01:05] ritchie postup ve psani skriptu |
dev:scripty:startup_script [31.12.2013 23:34] (aktuální) ritchie redirect stderr to stdout from minetest_mapper |
||
---|---|---|---|
Řádek 1: | Řádek 1: | ||
===== Startup script ===== | ===== Startup script ===== | ||
- | brandonuv [[http://pastebin.com/xE23Kb30|startup script]] je infinite loop: | + | Brandonův [[http://pastebin.com/xE23Kb30|startup script]] je infinite loop: |
while true do blabla done | 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\\ | + | proto je lepší udělat klasický skript minetest_start.sh s podmínkami zda mtserver běží, pokud jo, nic nedělat jinak zálohovat a cronem hlídat ten script. |
- | (17:24:24) Pitriss: Ritchie_: BTW v cronu se hodí ěnco ve stylu: \\ | + | |
+ | Do /etc/crontab byl vložen následující řádek: \\ | ||
'' | '' | ||
- | */5 * * * * minetest if [ `ps -e | grep -c minetestserver` = '0' ]; then /usr/local/bin/minetest_start.sh; fi | + | */5 * * * * minetest if [ `ps -e | grep -c minetest` = '0' ]; then /usr/local/bin/minetest_start.sh >> /opt/minetest-data/logs/minetest_start/minetest_start.log; fi |
'' | '' | ||
+ | |||
+ | Skript má v crontabu nastavené přesměrování výstupu do logu. | ||
<file bash minetest_start.sh> | <file bash minetest_start.sh> | ||
Řádek 17: | Řádek 20: | ||
### config section | ### config section | ||
+ | # All patches to directories must have a slash "/" at end! | ||
#patch to world | #patch to world | ||
Řádek 28: | Řádek 32: | ||
#patch to mapper directory | #patch to mapper directory | ||
MAPPER="/opt/minetest-git/minetest-mapper-cpp/" | MAPPER="/opt/minetest-git/minetest-mapper-cpp/" | ||
+ | #path to directory with minetestserver logs | ||
+ | LOGS="/opt/minetest-data/logs/" | ||
### end of config section | ### end of config section | ||
Řádek 45: | Řádek 51: | ||
#name of output map image | #name of output map image | ||
MAP="$NAME$NOW.png" | MAP="$NAME$NOW.png" | ||
+ | #patch and name of logfile | ||
+ | LOGFILE="$LOGS$NAME$NOW.txt" | ||
#debug of variables | #debug of variables | ||
Řádek 52: | Řádek 60: | ||
#echo MAP_DIR $MAP_DIR | #echo MAP_DIR $MAP_DIR | ||
#echo MAPPER $MAPPER | #echo MAPPER $MAPPER | ||
+ | #echo LOGS $LOGS | ||
#echo NOW $NOW | #echo NOW $NOW | ||
#echo NAME $NAME | #echo NAME $NAME | ||
Řádek 59: | Řádek 68: | ||
#echo MAP_OUT $MAP_OUT | #echo MAP_OUT $MAP_OUT | ||
#echo MAP $MAP | #echo MAP $MAP | ||
+ | #echo LOGFILE $LOGFILE | ||
+ | |||
+ | #date and time when job started | ||
+ | echo "Script started at time" $NOW | ||
#backup of world to *tar.gz in backup directory | #backup of world to *tar.gz in backup directory | ||
- | cd $MT_WORLD ; tar cfz $BACKUP_TGZ $NAME ; cd - | + | cd $MT_WORLD ; tar cfz $BACKUP_TGZ $NAME ; cd - &> /dev/null |
#symbolic link to $BACKUP$NAME-latest.tar.gz | #symbolic link to $BACKUP$NAME-latest.tar.gz | ||
- | cd $BACKUP ; ln -sf $TGZ $NAME-latest.tar.gz ; cd - | + | cd $BACKUP ; ln -sf $TGZ $NAME-latest.tar.gz ; cd - &> /dev/null |
#check if mapper is ready | #check if mapper is ready | ||
if [ -x "$MAPPER/minetest_mapper" ] ; then | if [ -x "$MAPPER/minetest_mapper" ] ; then | ||
#do a map | #do a map | ||
- | $MAPPER/minetest_mapper -i $WORLD -o $MAP_OUT | + | $MAPPER/minetest_mapper --draworigin --geometry -3000:-3000+6000+6000 -i $WORLD -o $MAP_OUT >> /opt/minetest-data/logs/minetest_start/minetest_start.log 2>&1 |
+ | #symbolic link to $MAP_DIR$NAME-latest.png | ||
+ | cd $MAP_DIR ; ln -sf $MAP $NAME-latest.png ; cd - &> /dev/null | ||
else | else | ||
Řádek 76: | Řádek 91: | ||
fi | fi | ||
+ | #run minetestserver | ||
+ | $MINETEST/bin/minetestserver &> $LOGFILE & | ||
</file> | </file> |