Nettoyage du script et quelques corrections

This commit is contained in:
2019-12-08 01:12:31 +01:00
parent 96f3b40afc
commit 60eafc9af1
2 changed files with 61 additions and 147 deletions

View File

@@ -29,7 +29,7 @@ usage() {
echo -e "\t--url <URL>: URL distante personnalisée."
echo -e "\t\tSi l'option --ssh est passée en option, il s'agira du chemin distant."
echo -e "\t-i --irrlicht\tChemin personnalisé des sources irrlicht."
echo -e "\t-p --postgresql\tSi vous voulez que le serveur soit configuré avec postgresql"
echo -e "\t-p --postgresql\tSi vous voulez que le serveur soit configuré avec postgresql. Sinon leveldb par défaut."
echo "version :"
echo -e "\tstable : Installation du serveur depuis sa branche stable. Suivez les instructions... (À priori stable)"
echo -e "\t1.1 : Installation du serveur depuis la branche 1.1 compatible Minetest 5.0. Suivez les instructions... (Stable)"
@@ -51,19 +51,6 @@ makeopt() {
makeopt=$(strip $1)
}
full() {
if [[ -n $URL ]]; then
echo "Full install... with "$URL
else
echo "ERREUR: Vous devez choisir l'option --ssh ou --https avec cette commande !"
usage
fi
}
clean() {
echo "clean install..."
}
postgresql() {
echo "Les indications à fournir ci-après nécessite d'avoir configuré un serveur postgresql au préalable. (Ctrl-C) pour annuler."
read -p "Indiquez l'adresse de la base de données : " pg_url
@@ -114,7 +101,11 @@ install_minetest() {
elif [[ $ver == "stable" || $ver == "1.1" || $ver == "dev" ]]; then
branch="-b stable-5"
fi
git clone --depth 1 $branch https://gitlab.com/minetest/minetest.git
if [[ -n $ssh ]]; then
git clone --depth 1 $branch $ssh\:minetest/minetest.git
else
git clone --depth 1 $branch https://gitlab.com/minetest/minetest.git
fi
verif
fi
@@ -161,7 +152,7 @@ install_minetest_game() {
elif [[ $ver == "1.1" ]]; then
branch="-b nalc-1.1"
elif [[ $ver == "stable" ]];then
branch="-b nalc"
branch="-b master"
elif [[ $ver == "dev" ]]; then
branch="-b nalc-dev"
fi
@@ -178,6 +169,44 @@ install_minetest_game() {
echo "Installation/Mise à jour du jeux NALC terminé."
}
install_mods() {
if [[ -d nalc-server-mods ]]; then
echo "Le dossier de mods est déjà présent. Que souhaitez-vous faire ?"
read -p "Choisissez parmi la liste, ([1]update, [2]clean, [3]cancel, [4]Ne rien faire) : " continue
if [[ $continue == 1 ]]; then
./upgrade.sh -m
elif [[ $continue == 2 ]]; then
rm -rf nalc-server-mods
elif [[ $continue == 3 ]]; then
echo "Mise à jour des mods annulé. Terminé."
exit 0
fi
fi
if [[ ! -d nalc-server-mods ]]; then
local branch="master"
if [[ $ver == "dev" ]]; then
branch="dev"
elif [[ $ver == "1.1" ]]; then
branch="stable-1.1"
elif [[ $ver == "1.0" ]]; then
branch="stable-1.0"
fi
git clone --depth 1 -b $branch $URL/nalc-server-mods.git
verif
./upgrade.sh -m
fi
if [[ -z $pg_dbname ]]; then
if [[ $ver == "1.0" ]]; then
cp worldmt-1.0.conf world.mt
elif [[ $ver == "1.1" || $ver == "stable" || $ver == "dev" ]]; then
cp worldmt-1.1.conf world.mt
fi
fi
}
install_world() {
local world_name="nalc-$ver"
if [[ -n $pg_dbname ]]; then
@@ -189,11 +218,6 @@ install_world() {
if [[ $continuer == 1 ]]; then
if [[ -n $pg_dbname ]]; then
read -p "Les BDD $pg_dbname et players-$pg_dbname ne seront pas effacées. À vous de le faire manuellement après ce script ! -- Press enter -- : " continuer
# dropdb $pg_dbname
# dropdb players-$pg_dbname
# createdb $pg_dbname
# createdb players-$pg_dbname
fi
if [[ -d "minetest/worlds/"$world_name"_old" ]]; then
@@ -219,115 +243,17 @@ install_world() {
./upgrade.sh -w $world_name -b $ver
mkdir $world_name/runes
mkdir -p minetest/worlds/$world_name/runes
fi
}
install_mods() {
if [[ -d nalc-server-mods ]]; then
echo "Le dossier de mods est déjà présent. Que souhaitez-vous faire ?"
read -p "Choisissez parmi la liste, ([1]update, [2]clean, [3]cancel, [4]Ne rien faire) : " continue
if [[ $continue == 1 ]]; then
cd nalc-server-mods
git pull
verif
git submodule update --init --recursive
verif
cd ..
elif [[ $continue == 2 ]]; then
rm -rf nalc-server-mods
elif [[ $continue == 3 ]]; then
echo "Mise à jour des mods annulé. Terminé."
exit 0
fi
fi
if [[ ! -d nalc-server-mods ]]; then
local branch="master"
if [[ $ver == "dev" ]]; then
branch="dev"
elif [[ $ver == "1.1" ]]; then
branch="stable-1.1"
elif [[ $ver == "1.0" ]]; then
branch="stable-1.0"
fi
git clone -b $branch $URL/nalc-server-mods.git
verif
cd nalc-server-mods
git submodule update --init --recursive
cd ..
fi
# Recréation des liens symboliques et du fichier world.mt (dans tous les cas)
rm minetest/mods/*
if [[ -z $pg_dbname ]]; then
if [[ $ver == "1.0" ]]; then
cp worldmt-1.0.conf world.mt
elif [[ $ver == "1.1" || $ver == "stable" || $ver == "dev" ]]; then
cp worldmt-1.1.conf world.mt
fi
fi
if [[ -d custom/mods ]]; then
ls custom/mods | while read -r mod; do
if [[ -d custom/mods/$mod ]]; then
rm nalc-server-mods/$mod
ln -s $(pwd)/custom/mods/$mod nalc-server-mods/$mod
fi
done
fi
local i=0
local md[1]="" # Mods to disable
local mods="3d_armor_ip 3d_armor_sfinv"
if [[ $ver == "1.0" ]]; then
mods="3d_armor_ip 3d_armor_sfinv worldedit_brush"
fi
for mod in $mods; do
i=$(( $i+1 ))
md[$i]=$mod
done
ls nalc-server-mods | while read -r mod; do
if [[ -d nalc-server-mods/$mod ]]; then
ln -s $(pwd)/nalc-server-mods/$mod minetest/mods/$mod
if [[ -a nalc-server-mods/$mod/modpack.txt ]]; then
ls nalc-server-mods/$mod | while read -r submod; do
if [[ -d nalc-server-mods/$mod/$submod ]]; then
local mod_enable="true"
for (( modn=1; modn<=$i; modn++ )); do
if [[ ${md[$modn]} == $submod ]]; then
mod_enable="false"
fi
done
echo "load_mod_$submod = $mod_enable" >> world.mt
fi
done
else
local mod_enable="true"
for (( modn=1; modn<=$i; modn++ )); do
if [[ ${md[$modn]} == $mod ]]; then
mod_enable="false"
fi
done
echo "load_mod_$mod = $mod_enable" >> world.mt
fi
fi
done
echo "Liens des mods créés dans minetest/mods/"
}
post_install() {
if [[ ! -a minetest/minetest.conf ]]; then
if [[ $ver == "stable" ]]; then
cp minetest-1.1.conf minetest/minetest.conf
else
cp minetest-$ver.conf minetest/minetest.conf
local world_name="nalc-$ver"
if [[ -n $pg_dbname ]]; then
world_name=$pg_dbname
fi
./upgrade.sh -w $world_name -b $ver -f mtconf
echo "Veuillez éditer le fichier $(pwd)/minetest/minetest.conf"
fi
@@ -337,24 +263,12 @@ post_install() {
fi
if [[ ! -a start.sh ]]; then
cp start.sh.example ./start.sh
cp start.sh.example start.sh
chmod u+x 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
# fix technic_worldgen crash
#cd server-0.4/mods/technic
#git checkout fb93388f06fe87ee75aaaf04cf6edcf01a26d981 technic_worldgen/oregen.lua
#cd ../../..
#echo "Fix technic_worldgen pour éviter crash appliqué."
# skindb updater (à relancer à la main plusieurs fois pour l'instant)
#if [[ -d nalc-server-mods/skinsdb/updater ]]; then
# cd nalc-server-mods/skinsdb/updater
# ./update_from_db.py
# cd ../../..
#fi
}
init() {