Ajout de divers scripts

This commit is contained in:
sys4-fr 2019-02-13 23:07:44 +01:00
parent 0b6b62daef
commit a906252c13
5 changed files with 59 additions and 27 deletions

View File

@ -1,31 +1,47 @@
#!/bin/bash #!/bin/bash
bak=/home/minetest/nalc-server-0.4/backup # Variables à modifier
bdd=nalc-0.4.17
worldname=nalc
servername=nalc-server-0.4.17-r1
serverpath=/home/minetest/$servername
bak=$serverpath/backup
world=$serverpath/minetest/worlds/$worldname
if [[ ! -d $bak ]]; then if [[ ! -d $bak ]]; then
mkdir $bak mkdir -p $bak
fi fi
bak_tmp=/var/tmp/nalc-0.4_dump bak_tmp=/var/tmp/$servername
if [[ ! -d $bak_tmp ]]; then if [[ ! -d $bak_tmp ]]; then
mkdir $bak_tmp mkdir $bak_tmp
fi fi
rm -r /home/minetest/nalc-server-0.4/minetest/worlds/nalc/rollback.sqlite cp $serverpath/minetest/minetest.conf $bak/
tar -I pbzip2 -cvf $bak/world.tar.bz2 /home/minetest/nalc-server-0.4/minetest/worlds/nalc cp $serverpath/start.sh $bak/
cp $serverpath/backup.sh $bak/
cp $serverpath/shutdown.sh $bak/
pg_dump nalc-0.4 > $bak_tmp/nalc-0.4.sql pushd $world
pg_dump players-nalc-0.4 > $bak_tmp/players-nalc-0.4.sql rm -r rollback.sqlite
tar -I pbzip2 -cf $bak/world.tar.bz2 .
popd
if [[ -e $bak/dump_sql.tar.bz2 ]]; then pg_dump -F c -f $bak_tmp/$bdd.dump $bdd
cd $bak pg_dump -F c -f $bak_tmp/players-$bdd.dump players-$bdd
tar -jxvf dump_sql.tar.bz2
cd .. pushd $bak_tmp
tar --label=SQL_DUMP-$servername -cf $bak/dump_sql.tar --remove-files *.dump
popd
log_dir=$serverpath/logs
[[ ! -d $log_dir ]] && mkdir $log_dir
pushd $log_dir
if [[ -f moredebug.log ]]; then
d=$(date +%Y-%m-%d.%H.%M.%S)
mv moredebug.log moredebug_$d.log
bzip2 moredebug_$d.log
tar --label=LOGS-$servername -rf moredebug-logs.tar --remove-files moredebug*.log.bz2
fi fi
popd
rdiff-backup --no-file-statistics $bak_tmp $bak
cd $bak
tar -I pbzip2 -cvf dump_sql.tar.bz2 --remove-files *.sql
cd ..
rm -rf $bak_tmp

View File

@ -337,7 +337,9 @@ post_install() {
if [[ ! -a start.sh ]]; then if [[ ! -a start.sh ]]; then
cp start.sh.example ./start.sh cp start.sh.example ./start.sh
echo "Veuiller éditer le fichier start.sh" echo "Veuillez éditer le fichier $(pwd)/start.sh"
echo "Veuillez éditer le fichier $(pwd)/backup.sh"
echo "Veuillez éditer le fichier $(pwd)/shutdown.sh"
fi fi
# fix technic_worldgen crash # fix technic_worldgen crash

View File

@ -165,7 +165,7 @@ mob_chance_multiplier = 0.5
#kpgmobs:deer = 51000,1 #kpgmobs:deer = 51000,1
#kpgmobs:jeraf = 51000,1 #kpgmobs:jeraf = 51000,1
#kpgmobs:medved = 100000,1 #kpgmobs:medved = 100000,1
#creeper:creeper = 25000,2 creeper:creeper = 50000,2
#mob_horse:horse = 60000,1 #mob_horse:horse = 60000,1
#mobs_turtles:turtle = 30000,1 #mobs_turtles:turtle = 30000,1
#mobs_turtles:seaturtle = 30000,1 #mobs_turtles:seaturtle = 30000,1

11
shutdown.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
serverpath=/home/minetest/nalc-server-0.4.17-r1
kill -s TERM $(pidof minetestserver)
sleep 10
kill -s TERM $(pidof -x $serverpath/start.sh)
$serverpath/backup.sh
$serverpath/start.sh&
exit 0

View File

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
DEBUG=~/nalc-server/logs/debug.log serverpath=/home/minetest/nalc-server
MOREDEBUG=~/nalc-server/logs/moredebug.log world=$serverpath/minetest/worlds/nalc
cd ~/nalc-server/minetest/bin DEBUG=$serverpath/logs/debug.log
MOREDEBUG=$serverpath/logs/moredebug.log
cd $serverpath/minetest/bin
while true while true
do do
@ -16,8 +19,8 @@ while true
echo "0" >/tmp/players_c.txt echo "0" >/tmp/players_c.txt
./minetestserver \ ./minetestserver \
--world ../worlds/nalc/ \ --world $world/ \
--config ../minetest.conf \ --config $serverpath/minetest/minetest.conf \
--gameid nalc_game \ --gameid nalc_game \
--port 30002 \ --port 30002 \
# --logfile $DEBUG # --logfile $DEBUG