diff --git a/install.sh b/install.sh index 9389851..8e124a1 100755 --- a/install.sh +++ b/install.sh @@ -265,6 +265,25 @@ post_install() { fi } +install_mtmapper() { + if [ -n $ssh ]; then + URL=$ssh\:minetest + else + URL="https://sys4.fr/gitea/minetest" + fi + + if [ ! -d "$(pwd)/minetestmapper" ]; then + git clone --depth 1 $URL/minetestmapper.git + verif + fi + + pushd "$(pwd)/minetestmapper" + git pull + cmake . + make -j$makeopt + popd +} + init() { ver=$(strip $1) @@ -282,6 +301,7 @@ init() { install_minetest_game install_mods install_world + install_mtmapper post_install echo "L'installation est terminé. Bravo !" else diff --git a/regen-map.sh b/regen-map.sh new file mode 100644 index 0000000..341c140 --- /dev/null +++ b/regen-map.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# Author: Sys4 +# Licence: GPLv3 + +# Script pour automatiser la création de la carte de nalc + +strip() { + echo "$1" | cut -d \' -f 2 +} + +verif() { + if [ $? -gt 0 ]; then + echo "Erreur ! Arrêt du script." + exit 1 + fi +} + +error() { + if [ -n "$1" ]; then + echo "ERREUR : $1 !" + else + echo "ERREUR : paramètres invalides !" >&2 + echo "utilisez l'option -h pour en savoir plus" >&2 + fi + exit 1 +} + +usage() { + echo "Usage : ./regen-map.sh [-h|--help] server_path worldname destination_path" + echo "Génère la carte de nalc vers le fichier $destination_path/nalc_map.png" +} + +action() { + [ -z "$1" ] && error "Argument manquant" + local serverpath="$1" + [ ! -d $serverpath ] && error "Le répertoire $serverpath n'existe pas" + + [ -z "$2" ] && error "Nom du world manquant" + local world_name="$2" + + local world="$serverpath/minetest/worlds/$world_name" + [ ! -d $world ] && error "Le répertoire $world n'existe pas" + + [ -z "$3" ] && error "Chemin de destination manquant" + local destination="$3" + [ ! -d destination ] && error "Le répertoire $destination n'existe pas" + + [ ! -d "$serverpath/minetestmapper" ] && error "minetestmapper ne semble pas installé" + [ ! -e "$serverpath/colors.txt" ] && error "$serverpath/colors.txt manquant" + + pushd "$serverpath/minetestmapper" + ./minetestmapper -i "$world" -o /tmp/nalc_map.png \\ + --colors "$serverpath/colors.txt" --min-y -25 --max-y 300 \\ + --geometry -5000:-5000+10000+10000 + verif + popd + + mv /tmp/nalc_map.png "$destination/" + verif +} + +# Pas de paramètre +[[ $# -lt 1 ]] && usage + +# -o : Options courtes +# -l : Options longues +options=$(getopt -o h -l help -- "$@") + +# Éclatement de $options en $1, $2... +set -- $options + +while true; do + case "$1" in + -h|--help) + usage + exit 0;; + --) + shift;; + *) + action + exit 0 + shift;; + esac +done + +exit 0 diff --git a/shutdown.sh b/shutdown.sh index 1cddbeb..56008c2 100755 --- a/shutdown.sh +++ b/shutdown.sh @@ -5,18 +5,22 @@ serverpath=/home/minetest/nalc-stable world=nalc-stable world_file=all # news|technic|fbn|fbnp|bitchange|christmas|randommsg branch=stable # 1.0|1.1|dev +mountpoint=/mnt/demonix.fr +mapdest=$mountpoint/www bak=0 update=0 restart=0 +regenmap=0 usage() { - echo "usage: ./shutdown.sh [-h|--help] [-r|--restart] [-b|--bak] [-u|--update]" - echo "Options:" - echo -e "\t-h --help\tAffiche cette aide." - echo -e "\t-r --restart\tRedémarre le serveur après arrêt." - echo -e "\t-b --bak\tRéalise une sauvegarde après arrêt." - echo -e "\t-u --update\tRéalise une mise à jour après arrêt." - exit 0 + echo "usage: ./shutdown.sh [-h|--help] [-r|--restart] [-b|--bak] [-u|--update]" + echo "Options:" + echo -e "\t-h --help\tAffiche cette aide." + echo -e "\t-r --restart\tRedémarre le serveur après arrêt." + echo -e "\t-b --bak\tRéalise une sauvegarde après arrêt." + echo -e "\t-u --update\tRéalise une mise à jour après arrêt." + echo -e "\t-m --regen-map\tRégénère une carte du monde." + exit 0 } action() { @@ -26,7 +30,14 @@ action() { kill -s TERM $(pidof -x $serverpath/start.sh) [[ $bak -eq 1 ]] && $serverpath/backup.sh - [[ $update -eq 1 ]] && $serverpath/upgrade.sh -s $serverpath -m -w $world -b $branch -f $world_file + if [ $regenmap -eq 1 ]; then + mount $mountpoint + sleep 5 + $serverpath/regen_map.sh $serverpath $world $mapdest + umount $mountpoint + fi + + [[ $update -eq 1 ]] && $serverpath/upgrade.sh -s $serverpath -m -w $world -b $branch -f $world_file [[ $restart -eq 1 ]] && $serverpath/start.sh& exit 0 @@ -39,7 +50,7 @@ action() { # -o : Options courtes # -l : options longues -OPT=$(getopt -o b,r,h,u -l bak,restart,help,update -- "$@") +OPT=$(getopt -o b,r,h,u,m -l bak,restart,help,update,regen-map -- "$@") # éclatement de $options en $1, $2... set -- $OPT @@ -52,11 +63,14 @@ while true; do -r|--restart) restart=1 shift;; - -h|--help) - usage;; - -u|--update) - update=1 - shift;; + -h|--help) + usage;; + -u|--update) + update=1 + shift;; + -m|--regen-map) + regenmap=1 + shift;; --) shift;; *)