Reindent with tabs
This commit is contained in:
128
genmap.sh
128
genmap.sh
@@ -5,75 +5,75 @@
|
||||
# Script pour automatiser la création de la carte de nalc
|
||||
|
||||
strip() {
|
||||
echo "$1" | cut -d \' -f 2
|
||||
echo "$1" | cut -d \' -f 2
|
||||
}
|
||||
|
||||
verif() {
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Erreur ! Arrêt du script."
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
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 : ./genmap.sh [-h|--help] server_path worldname destination_path"
|
||||
echo "Génère la carte de nalc vers le fichier destination_path/nalc_map.png"
|
||||
echo "Usage : ./genmap.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=$(strip "$1")
|
||||
[ ! -d "$serverpath" ] && error "Le répertoire $serverpath n'existe pas"
|
||||
[ -z "$1" ] && error "Argument manquant"
|
||||
local serverpath=$(strip "$1")
|
||||
[ ! -d "$serverpath" ] && error "Le répertoire $serverpath n'existe pas"
|
||||
|
||||
[ -z "$2" ] && error "Nom du world manquant"
|
||||
local world_name=$(strip "$2")
|
||||
|
||||
local world="$serverpath/minetest/worlds/$world_name"
|
||||
[ ! -d "$world" ] && error "Le répertoire $world n'existe pas"
|
||||
[ -z "$2" ] && error "Nom du world manquant"
|
||||
local world_name=$(strip "$2")
|
||||
|
||||
[ -z "$3" ] && error "Chemin de destination manquant"
|
||||
local destination=$(strip "$3")
|
||||
[ ! -d "$destination" ] && error "Le répertoire $destination n'existe pas"
|
||||
|
||||
[ ! -d "$serverpath/minetestmapper" ] && error "minetestmapper ne semble pas installé"
|
||||
[ ! -d "$serverpath/leaftest" ] && error "leaftest ne semble pas installé"
|
||||
[ ! -e "$serverpath/colors.txt" ] && error "$serverpath/colors.txt manquant"
|
||||
local world="$serverpath/minetest/worlds/$world_name"
|
||||
[ ! -d "$world" ] && error "Le répertoire $world n'existe pas"
|
||||
|
||||
# Copie du dossier leaftest vers /tmp puis on l'exécute de là
|
||||
local config="$serverpath/minetest/minetest.conf"
|
||||
local workdir=$(mktemp -d "/tmp/minetest-mapper.XXXXXXXXX")
|
||||
local spawn=$(grep "^static_spawnpoint" "$config" | tr -d " " | cut -f 2 -d "=");
|
||||
local spawnx=$(cut -f 1 -d "," <<<$spawn)
|
||||
local spawnz=$(cut -f 3 -d "," <<<$spawn)
|
||||
local mapsize=12288
|
||||
|
||||
cp -a "$serverpath/leaftest" $workdir
|
||||
cp "$serverpath/colors.txt" $workdir/leaftest
|
||||
|
||||
pushd $workdir/leaftest
|
||||
|
||||
MAPPERDIR="$serverpath/minetestmapper" \
|
||||
MAPPERPARAMS="--colors $serverpath/colors.txt \
|
||||
--min-y -25 --max-y 300" \
|
||||
JOBNUM=$(nproc) \
|
||||
$workdir/leaftest/mapper.sh "$world" $spawnx,$spawnz $mapsize
|
||||
[ -z "$3" ] && error "Chemin de destination manquant"
|
||||
local destination=$(strip "$3")
|
||||
[ ! -d "$destination" ] && error "Le répertoire $destination n'existe pas"
|
||||
|
||||
# Copie de leaftest vers le dossier web distant normalement déjà monté
|
||||
rm -rf "$destination/$world_name"
|
||||
cp -rL $workdir/leaftest/www "$destination/$world_name"
|
||||
popd
|
||||
|
||||
rm -rf $workdir
|
||||
[ ! -d "$serverpath/minetestmapper" ] && error "minetestmapper ne semble pas installé"
|
||||
[ ! -d "$serverpath/leaftest" ] && error "leaftest ne semble pas installé"
|
||||
[ ! -e "$serverpath/colors.txt" ] && error "$serverpath/colors.txt manquant"
|
||||
|
||||
# Copie du dossier leaftest vers /tmp puis on l'exécute de là
|
||||
local config="$serverpath/minetest/minetest.conf"
|
||||
local workdir=$(mktemp -d "/tmp/minetest-mapper.XXXXXXXXX")
|
||||
local spawn=$(grep "^static_spawnpoint" "$config" | tr -d " " | cut -f 2 -d "=");
|
||||
local spawnx=$(cut -f 1 -d "," <<<$spawn)
|
||||
local spawnz=$(cut -f 3 -d "," <<<$spawn)
|
||||
local mapsize=12288
|
||||
|
||||
cp -a "$serverpath/leaftest" $workdir
|
||||
cp "$serverpath/colors.txt" $workdir/leaftest
|
||||
|
||||
pushd $workdir/leaftest
|
||||
|
||||
MAPPERDIR="$serverpath/minetestmapper" \
|
||||
MAPPERPARAMS="--colors $serverpath/colors.txt \
|
||||
--min-y -25 --max-y 300" \
|
||||
JOBNUM=$(nproc) \
|
||||
$workdir/leaftest/mapper.sh "$world" $spawnx,$spawnz $mapsize
|
||||
|
||||
# Copie de leaftest vers le dossier web distant normalement déjà monté
|
||||
rm -rf "$destination/$world_name"
|
||||
cp -rL $workdir/leaftest/www "$destination/$world_name"
|
||||
popd
|
||||
|
||||
rm -rf $workdir
|
||||
}
|
||||
|
||||
# Pas de paramètre
|
||||
@@ -87,17 +87,17 @@ options=$(getopt -o h -l help -- "$@")
|
||||
set -- $options
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0;;
|
||||
--)
|
||||
shift;;
|
||||
*)
|
||||
action $1 $2 $3
|
||||
exit 0
|
||||
shift;;
|
||||
esac
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0;;
|
||||
--)
|
||||
shift;;
|
||||
*)
|
||||
action $1 $2 $3
|
||||
exit 0
|
||||
shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user