From 60eafc9af1310b73c5c26162ac6af4d162ecd886 Mon Sep 17 00:00:00 2001 From: sys4 Date: Sun, 8 Dec 2019 01:12:31 +0100 Subject: [PATCH] Nettoyage du script et quelques corrections --- install.sh | 190 +++++++++++++++-------------------------------------- upgrade.sh | 18 ++--- 2 files changed, 61 insertions(+), 147 deletions(-) diff --git a/install.sh b/install.sh index af1ddf4..e6c96ef 100755 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ usage() { echo -e "\t--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() { diff --git a/upgrade.sh b/upgrade.sh index 74c0bce..1097375 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -38,7 +38,7 @@ usage() { echo -e "\t-b --branch \tBranche concerné" echo -e "\t-f --world-file \tFichier(s) a mettre à jour :" echo -e "\t doit être une des valeur suivante :" - echo -e "\tall\t\tTous les fichiers seront mis à jours" + echo -e "\tall\t\tToutes les mise à jour suivantes seront executés sauf 'mtconf'" echo -e "\tnews\t\tLes news du serveur" echo -e "\ttechnic\t\tLes paramètres de technic" echo -e "\tfbn\t\tLes paramètres de forbidden_names" @@ -51,10 +51,10 @@ usage() { echo "Exemples:" echo -e "\tMise à jour des mods :" echo -e "\t$ ./upgrade.sh -m" - echo -e "\tMise à jour des fichiers world :" - echo -e "\t$ ./upgrade.sh -w nalc-stable -b stable" - echo -e "\tMise à jour des mods et des news :" - echo -e "\t$ ./upgrade.sh -m -w nalc-1.1 -b 1.1 -f news" + echo -e "\tMise à jour du fichier minetest.conf :" + echo -e "\t$ ./upgrade.sh -w nalc-stable -b stable -f mtconf" + echo -e "\tMise à jour complète (mods et fichiers world, sauf minetest.conf) :" + echo -e "\t$ ./upgrade.sh -m -w nalc-1.1 -b 1.1" } regen_worldmt() { @@ -88,12 +88,12 @@ regen_worldmt() { local mods_minetest=$serverpath/minetest/mods local mods_custom=$serverpath/custom/mods - rm $mods_minetest/* + rm -f $mods_minetest/* if [[ -d $mods_custom ]]; then ls $mods_custom | while read -r mod; do if [[ -d $mods_cutom/$mod ]]; then - rm $mods_path/$mod + rm -f $mods_path/$mod ln -s $mods_custom/$mod $mods_path/$mod fi done @@ -170,7 +170,7 @@ update_world() { fi if [[ $WORLD_FILE == "all" ]]; then - WORLD_FILE="news technic fbn fbnp bitchange christmas randommsg worldmt mtconf" + WORLD_FILE="news technic fbn fbnp bitchange christmas randommsg worldmt" fi for w_file in $WORLD_FILE; do @@ -202,7 +202,7 @@ update_world() { worldmt) do_copy=0 regen_worldmt;; - mtconf) + mtconf) # Exception ici car n'est pas un fichier world. Doit être appelé seul. file_dest=$serverpath/minetest/minetest.conf file=$serverpath/minetest-$BRANCH.conf;; *)