2018-03-15 23:49:09 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
# Fonctions
|
|
|
|
strip() {
|
|
|
|
echo $1 | cut -d \' -f 2
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:49:09 +01:00
|
|
|
verif() {
|
2018-03-21 01:28:29 +01:00
|
|
|
if [[ $? -gt 0 ]]; then
|
2018-03-22 10:07:56 +01:00
|
|
|
echo "Erreur ! Arrêt du script."
|
|
|
|
exit 1
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
2018-03-15 23:49:09 +01:00
|
|
|
}
|
|
|
|
|
2018-03-16 23:47:34 +01:00
|
|
|
error() {
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "ERREUR : Vérifiez vos paramètres !" >&2
|
|
|
|
echo "Utilisez l'option -h pour en savoir plus" >&2
|
|
|
|
exit 1
|
2018-03-16 23:47:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
usage() {
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "Usage: ./install.sh [options] [--] <arg>"
|
|
|
|
echo "Options :"
|
|
|
|
echo "--help | -h : Affiche l'aide."
|
2018-03-24 12:14:37 +01:00
|
|
|
echo "--makeopt | -j : Passer des options à make."
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "--ssh <user@host>: Identifiants ssh."
|
|
|
|
echo "--url <URL>: URL distante personnalisée."
|
2018-03-24 12:14:37 +01:00
|
|
|
echo "--irrlicht | -i : Chemin personnalisé des sources irrlicht."
|
2018-03-21 01:28:29 +01:00
|
|
|
echo -e "\tSi l'option --ssh est passée en option, il s'agira du chemin distant."
|
|
|
|
echo "Commandes :"
|
2018-03-24 12:14:37 +01:00
|
|
|
echo -e "\t0.5 : Installation du serveur avec minetest-0.5.x. Suivez les instructions..."
|
|
|
|
echo -e "\t0.4 : Installation du serveur avec minetest-0.4.x. Suivez les instructions..."
|
2018-03-21 01:28:29 +01:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
ssh() {
|
|
|
|
ssh=$(strip $1)
|
|
|
|
echo "Installation avec identifiants ssh : $ssh"
|
|
|
|
}
|
|
|
|
|
|
|
|
url() {
|
|
|
|
url=$(strip $1)
|
2018-03-16 23:47:34 +01:00
|
|
|
}
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
makeopt() {
|
|
|
|
makeopt=$(strip $1)
|
|
|
|
}
|
|
|
|
|
|
|
|
full() {
|
|
|
|
if [[ -n $URL ]]; then
|
2018-03-22 10:07:56 +01:00
|
|
|
echo "Full install... with "$URL
|
2018-03-21 01:28:29 +01:00
|
|
|
else
|
2018-03-22 10:07:56 +01:00
|
|
|
echo "ERREUR: Vous devez choisir l'option --ssh ou --https avec cette commande !"
|
|
|
|
usage
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
clean() {
|
|
|
|
echo "clean install..."
|
|
|
|
}
|
|
|
|
|
2018-03-24 12:14:37 +01:00
|
|
|
install_0.4() {
|
|
|
|
if [[ -d server-0.4 ]]; then
|
|
|
|
echo "Installation précédente détecté. Voulez-vous faire la mise à jour ?"
|
|
|
|
read -p "Continuer ? (y or n) " continuer
|
|
|
|
if [[ $continuer == "y" ]]; then
|
|
|
|
cd server-0.4
|
|
|
|
git pull
|
|
|
|
verif
|
|
|
|
git submodule update --remote --recursive
|
|
|
|
verif
|
2018-03-24 14:06:26 +01:00
|
|
|
cd ..
|
2018-03-24 12:14:37 +01:00
|
|
|
else
|
|
|
|
echo "Mise à jour annulé."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git clone https://github.com/sys4-fr/server-nalc.git server-0.4
|
|
|
|
verif
|
|
|
|
cd server-0.4
|
|
|
|
git submodule update --init --recursive
|
|
|
|
verif
|
2018-03-24 14:06:26 +01:00
|
|
|
cd ..
|
2018-03-24 12:14:37 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
install_minetest() {
|
|
|
|
if [[ -z $makeopt ]]; then
|
2018-03-24 12:14:37 +01:00
|
|
|
local makeopt=$(grep -c processor /proc/cpuinfo)
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -d minetest ]]; then
|
|
|
|
echo "Installation précédente de Minetest détecté."
|
|
|
|
read -p "Mettre à jour ? (y,n,clean,cancel) : " continue
|
|
|
|
if [[ $continue == "clean" ]]; then
|
|
|
|
echo "Attention ! Cela va supprimer définitivement toutes les données."
|
|
|
|
read -p "Êtes-vous certains de vouloir continuer ? (y or n) : " continue
|
|
|
|
if [[ $continue == "y" ]]; then
|
2018-03-22 10:07:56 +01:00
|
|
|
rm -rf minetest
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "Répertoire minetest supprimé."
|
|
|
|
else
|
|
|
|
echo "Installation annulée. Fin"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
elif [[ $continue == "y" ]]; then
|
2018-03-22 10:07:56 +01:00
|
|
|
cd minetest
|
|
|
|
git pull
|
|
|
|
verif
|
|
|
|
cd ..
|
2018-03-21 01:28:29 +01:00
|
|
|
elif [[ $continue == "cancel" ]]; then
|
|
|
|
echo "Installation annulée. Fin"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d minetest ]]; then
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ $ver == "0.4" ]]; then
|
|
|
|
git clone -b backport-0.4 https://github.com/minetest/minetest.git
|
|
|
|
else
|
|
|
|
git clone $URL/minetest.git
|
|
|
|
fi
|
2018-03-22 10:07:56 +01:00
|
|
|
verif
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
|
|
|
|
2018-03-24 12:14:37 +01:00
|
|
|
echo "Minetest va être (re)compilé..."
|
2018-03-21 01:28:29 +01:00
|
|
|
sleep 3
|
2018-03-22 10:07:56 +01:00
|
|
|
cd minetest
|
2018-03-24 19:04:11 +01:00
|
|
|
cmake . -DBUILD_CLIENT=0 -DBUILD_SERVER=1 -DENABLE_SOUND=0 -DENABLE_SYSTEM_GMP=1 $irrlicht_src -DENABLE_LEVELDB=0 -DENABLE_REDIS=1 -DENABLE_POSTGRESQL=1 -DRUN_IN_PLACE=1 -DENABLE_GETTEXT=1 -DENABLE_FREETYPE=1 -DENABLE_LUAJIT=1 -DENABLE_CURL=1
|
2018-03-22 10:07:56 +01:00
|
|
|
make -j$makeopt
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "Installation de Minetest terminé."
|
2018-03-22 10:07:56 +01:00
|
|
|
cd ..
|
2018-03-21 01:28:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_minetest_game() {
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ -d minetest_game && ! $ver == "0.4" ]]; then
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "Installation précédente du jeux Minetest détecté."
|
2018-03-22 10:07:56 +01:00
|
|
|
read -p "Mettre à jour ? (y,n,clean,cancel) " continue
|
|
|
|
if [[ $continue == "y" ]]; then
|
|
|
|
cd minetest_game
|
|
|
|
git pull
|
|
|
|
verif
|
|
|
|
cd ..
|
|
|
|
echo "Mise à jour du jeux Minetest depuis dépôt distant terminé."
|
|
|
|
elif [[ $continue == "clean" ]]; then
|
|
|
|
echo "/!\ Cette action va effacer les données du répertoire minetest_game"
|
|
|
|
read -p "Êtes-vous sûr de vouloir continuer ? (y or n) " continue
|
|
|
|
if [[ $continue == "y" ]]; then
|
|
|
|
rm -rf minetest_game
|
|
|
|
echo "Jeux Minetest supprimé."
|
|
|
|
else
|
|
|
|
echo "Mise à jour annulée. Terminé."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
elif [[ $continue == "cancel" ]]; then
|
|
|
|
echo "Mise à jour annulée. Terminé."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d minetest_game ]]; then
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ ! $ver == "0.4" ]]; then
|
|
|
|
git clone $URL/minetest_game.git
|
|
|
|
verif
|
|
|
|
echo "Clonage de minetest_game terminé."
|
|
|
|
else
|
|
|
|
ln -s $(pwd)/server-0.4/minetest_game minetest_game
|
|
|
|
fi
|
|
|
|
elif [[ $ver == "0.4" ]]; then
|
|
|
|
if [[ -a minetest_game ]]; then
|
|
|
|
rm minetest_game
|
|
|
|
fi
|
|
|
|
ln -s $(pwd)/server-0.4/minetest_game minetest_game
|
2018-03-22 10:07:56 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -a minetest/games/minetest_game ]]; then
|
|
|
|
ln -s $(pwd)/minetest_game minetest/games/minetest_game
|
|
|
|
echo "Lien symbolique minetest/games/minetest_game vers $(pwd)/minetest_game créé."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installation/Mise à jour du jeux Minetest terminé."
|
|
|
|
}
|
|
|
|
|
|
|
|
install_world() {
|
|
|
|
if [[ -d minetest/worlds/nalc ]]; then
|
|
|
|
echo "Une map est déjà présente. Que souhaitez-vous faire ?"
|
|
|
|
read -p "Choisissez parmi la liste ([1]Nouveau, [2]Utiliser) : " continuer
|
|
|
|
if [[ $continuer == 1 ]]; then
|
|
|
|
if [[ -d minetest/worlds/nalc_old ]]; then
|
|
|
|
rm -rf minetest/worlds/nalc_old
|
|
|
|
fi
|
|
|
|
|
|
|
|
mv minetest/worlds/nalc minetest/worlds/nalc_old
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d minetest/worlds/nalc ]]; then
|
|
|
|
mkdir -p minetest/worlds/nalc
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ $ver == "0.4" ]]; then
|
2018-03-24 14:06:26 +01:00
|
|
|
ln -s $(pwd)/server-0.4/worlds/minetestforfun/world.mt minetest/worlds/nalc/world.mt
|
2018-03-24 12:14:37 +01:00
|
|
|
else
|
|
|
|
ln -s $(pwd)/world.mt minetest/worlds/nalc/world.mt
|
|
|
|
fi
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
2018-03-22 10:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_mods() {
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ $ver == "0.4" ]]; then
|
|
|
|
if [[ -d minetest/mods ]]; then
|
|
|
|
rm -rf minetest/mods
|
|
|
|
ln -s $(pwd)/server-0.4/mods minetest/mods
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
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 --remote --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
|
|
|
|
git clone $URL/nalc-server-mods.git
|
2018-03-22 10:07:56 +01:00
|
|
|
verif
|
2018-03-24 12:14:37 +01:00
|
|
|
cd nalc-server-mods
|
|
|
|
git submodule update --init --recursive
|
2018-03-22 10:07:56 +01:00
|
|
|
cd ..
|
|
|
|
fi
|
2018-03-24 12:14:37 +01:00
|
|
|
|
|
|
|
# Recréation des liens symboliques et du fichier world.mt (dans tous les cas)
|
|
|
|
rm minetest/mods/*
|
|
|
|
|
|
|
|
if [[ -a world.mt ]]; then
|
|
|
|
rm world.mt
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp worldmt.conf world.mt
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
echo "load_mod_$submod = true" >> world.mt
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "load_mod_$mod = true" >> world.mt
|
|
|
|
fi
|
2018-03-22 10:07:56 +01:00
|
|
|
fi
|
|
|
|
done
|
2018-03-24 12:14:37 +01:00
|
|
|
|
|
|
|
echo "Liens des mods créés dans minetest/mods/"
|
2018-03-22 10:07:56 +01:00
|
|
|
fi
|
2018-03-21 01:28:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-24 14:06:26 +01:00
|
|
|
post_install() {
|
|
|
|
if [[ ! -a minetest/minetest.conf ]]; then
|
|
|
|
if [[ $ver == "0.4" ]]; then
|
|
|
|
cp server-0.4/minetest.conf minetest/minetest.conf
|
|
|
|
else
|
|
|
|
cp minetest.conf minetest/minetest.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Veuillez éditer le fichier $(pwd)/minetest/minetest.conf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d logs ]]; then
|
|
|
|
mkdir logs
|
|
|
|
fi
|
|
|
|
|
2018-03-24 14:09:33 +01:00
|
|
|
if [[ $ver == "0.4" ]]; then
|
|
|
|
if [[ ! -a start.sh ]]; then
|
2018-03-24 14:06:26 +01:00
|
|
|
cp server-0.4/other_things/scripts/Server-side/script/start-mff.sh ./start.sh
|
|
|
|
echo "Veuiller éditer le fichier start.sh"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
init() {
|
2018-03-24 12:14:37 +01:00
|
|
|
ver=$(strip $1)
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
if [[ -n $ssh && -n $url ]]; then
|
|
|
|
URL=$ssh\:$url
|
|
|
|
elif [[ -n $url ]]; then
|
|
|
|
URL=$url
|
|
|
|
else
|
|
|
|
URL="https://github.com/sys4-fr"
|
|
|
|
fi
|
|
|
|
|
|
|
|
read -p "L'installation va démarrer. Continuer ? (y or n) : " continue
|
|
|
|
if [[ $continue == "y" ]]; then
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ $ver == "0.4" ]]; then
|
|
|
|
install_0.4
|
|
|
|
fi
|
2018-03-21 01:28:29 +01:00
|
|
|
install_minetest
|
|
|
|
install_minetest_game
|
|
|
|
install_mods
|
2018-03-22 10:07:56 +01:00
|
|
|
install_world
|
2018-03-24 14:06:26 +01:00
|
|
|
post_install
|
2018-03-21 01:28:29 +01:00
|
|
|
echo "L'installation est terminé. Bravo !"
|
|
|
|
else
|
|
|
|
echo "Installation annulée. Fin."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
action() {
|
|
|
|
local arg=$(strip $1)
|
2018-03-24 12:14:37 +01:00
|
|
|
if [[ $arg == "0.5" ]]; then
|
|
|
|
init "0.5"
|
|
|
|
elif [[ $arg == "0.4" ]]; then
|
|
|
|
init "0.4"
|
2018-03-21 01:28:29 +01:00
|
|
|
else
|
2018-03-22 10:07:56 +01:00
|
|
|
error
|
2018-03-21 01:28:29 +01:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2018-03-24 12:14:37 +01:00
|
|
|
irrlicht() {
|
|
|
|
local arg=$(strip $1)
|
|
|
|
if [[ -d $arg ]]; then
|
|
|
|
irrlicht_src="-DIRRLICHT_SOURCE_DIR=$arg"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:28:29 +01:00
|
|
|
# Pas de paramètre
|
|
|
|
#[[ $# -lt 1 ]] && error
|
|
|
|
# ou
|
|
|
|
[[ $# -lt 1 ]] && usage
|
|
|
|
|
|
|
|
# -o : Options courtes
|
|
|
|
# -l : options longues
|
2018-03-24 12:14:37 +01:00
|
|
|
OPT=$(getopt -o h,j:,i: -l help,url:,ssh:,makeopt:,irrlicht: -- "$@")
|
2018-03-21 01:28:29 +01:00
|
|
|
|
|
|
|
# éclatement de $options en $1, $2...
|
|
|
|
set -- $OPT
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-h|--help)
|
|
|
|
usage;;
|
2018-03-24 12:14:37 +01:00
|
|
|
-i|--irrlicht)
|
|
|
|
irrlicht $2
|
|
|
|
shift 2;;
|
2018-03-21 01:28:29 +01:00
|
|
|
--ssh)
|
|
|
|
ssh $2
|
|
|
|
shift 2;;
|
|
|
|
--url)
|
|
|
|
url $2
|
|
|
|
shift 2;;
|
|
|
|
-j|--makeopt)
|
|
|
|
makeopt $2
|
|
|
|
shift 2;;
|
|
|
|
--)
|
|
|
|
shift;;
|
|
|
|
*)
|
|
|
|
action $1
|
|
|
|
shift;;
|
|
|
|
esac
|
|
|
|
done
|