Merge branch 'dev'
This commit is contained in:
commit
119a64d81c
169
README.md
169
README.md
@ -1,13 +1,166 @@
|
|||||||
# server-nalc
|
|
||||||
|
|
||||||
Les fichiers pour installer le serveur NALC.
|
# Description
|
||||||
|
|
||||||
## Installation
|
The files to install the Minetest NALC server.
|
||||||
Lancer le script ./install.sh
|
|
||||||
|
|
||||||
Pour l'aide : ./install.sh --help
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
# Installation
|
||||||
*Licence : GPL v3*
|
|
||||||
|
Start the install.sh script and follow instructions.
|
||||||
|
|
||||||
|
Help: ./install.sh –help
|
||||||
|
|
||||||
|
|
||||||
|
# Requirements
|
||||||
|
|
||||||
|
- Official Minetest server must already be installed on your GNU/Linux system. If it is not the case, please refers to the <https://minetest.net> website for the installation instructions.
|
||||||
|
- You'll also need 'git', 'cmake' and 'make' programs installed.
|
||||||
|
|
||||||
|
|
||||||
|
# Examples of installation
|
||||||
|
|
||||||
|
|
||||||
|
## For a production server intended to be publicly available
|
||||||
|
|
||||||
|
We suppose that you have already installed Minetest server from your package manager.
|
||||||
|
|
||||||
|
The home of the 'minetest' user is located to /var/lib/minetest and you have the write access to it.
|
||||||
|
|
||||||
|
1. Create the dir '\\/var/lib/minetest/.minetest' if not exist.
|
||||||
|
2. cd /var/lib/minetest
|
||||||
|
3. git clone –depth 1 -b master <https://sys4.fr/gitea/nalc/nalc-server.git>
|
||||||
|
4. cd nalc-server
|
||||||
|
5. ./install.sh -d \\/var/lib/minetest/.minetest
|
||||||
|
6. Follow the instructions
|
||||||
|
|
||||||
|
|
||||||
|
## For a test server
|
||||||
|
|
||||||
|
We suppose you have already installed a production server that is actually in use and stable. But you want to install another one in palallel on the same system in order to test the development version of NALC.
|
||||||
|
|
||||||
|
For the next steps we will be logged in as a normal user:
|
||||||
|
|
||||||
|
1. cd
|
||||||
|
2. Create the dir '~/.minetest' if it not exist.
|
||||||
|
3. No need to download the server files again because they are already downloaded in the dir /var/lib/minetest/nalc-server. So you can just do a 'mkdir ~/nalc-dev'. But you can always do a 'git clone <https://sys4.fr/gitea/nalc/nalc-server.git> ~/nalc-dev' if you prefer. Whatever your choice and for the next steps we will refer to the install dir as '$INSTALL'.
|
||||||
|
4. $INSTALL/install.sh -d ~/.minetest -w test -P 30001 –branch dev ~/nalc-dev
|
||||||
|
5. Follow the instructions
|
||||||
|
|
||||||
|
|
||||||
|
## Case of a custom Minetest installation
|
||||||
|
|
||||||
|
We suppose you have compiled Minetest from sources with the CMAKE option RUNINPLACE=TRUE. The location of your installation is ~/games/minetest.
|
||||||
|
|
||||||
|
1. cd ~/games
|
||||||
|
2. git clone <https://sys4.fr/gitea/nalc/nalc-server.git>
|
||||||
|
3. cd nalc-server
|
||||||
|
4. ./install.sh -b ~/games/minetest/bin/minetestserver -d ~/games/minetest
|
||||||
|
5. Follow the instructions
|
||||||
|
|
||||||
|
|
||||||
|
## Other cases
|
||||||
|
|
||||||
|
Other combinaisons are possibles and I cannot describe all of them. Don't hesitate to read the help of the script with –help option and do your own tests :)
|
||||||
|
|
||||||
|
|
||||||
|
# Add or disable mods
|
||||||
|
|
||||||
|
If you want to add mods you can do it easily. For that you can create the dir $DESTINATION/custom/mods where $DESTINATION is the dir where you have installed the server (the one containing the nalc.conf file).
|
||||||
|
Then copy your mods and modpacks in $DESTINATION/custom/mods and you need to execute $INSTALL/upgrade.sh -s $DESTINATION -w <world> -b <version> -f worldmt for regenerating the world.mt file of your world.
|
||||||
|
Replace <world> by your world name.
|
||||||
|
Replace <version> by the branch name specified during the installation, either 'stable', 'dev' or 'exp'.
|
||||||
|
|
||||||
|
If you want to disable mods you need to edit the file $DESTINATION/modsdisabled.txt and add one mod name per line.
|
||||||
|
Then execute again $INSTALL/upgrade.sh -s $DESTINATION -w <world> -b <version> -f worldmt.
|
||||||
|
|
||||||
|
Note: Depending on how you have installed NALC server, but $INSTALL and $DESTINATION can point to the same directory. If it's the case you can ommit the -s option.
|
||||||
|
|
||||||
|
|
||||||
|
# Start/Stop the server
|
||||||
|
|
||||||
|
|
||||||
|
## Use provided scripts
|
||||||
|
|
||||||
|
You can rename the $INSTALL/start.sh.example file to start.sh and give it executable permissions.
|
||||||
|
Then launch the server with the command $INSTALL/start.sh -s $DESTINATION.
|
||||||
|
|
||||||
|
Note: -s option can be ommited if you launch the script from the dir $DESTINATION.
|
||||||
|
|
||||||
|
For shutting down the server press CTRL-C.
|
||||||
|
|
||||||
|
You can edit the start.sh script for your needs.
|
||||||
|
|
||||||
|
|
||||||
|
## Use openrc to start/stop NALC as a daemon
|
||||||
|
|
||||||
|
We suppose minetest is installed from portage with the +server USE flag and NALC server is installed in the home of the minetest user `/var/lib/minetest/nalc-server`. If you would use your Gentoo/Calculate Linux system init to start/stop NALC server as a service then you can follow theses steps:
|
||||||
|
|
||||||
|
1. Edit your `/etc/conf.d/minetest-server` file like that:
|
||||||
|
|
||||||
|
# /etc/conf.d/minetest-server: config file for /etc/init.d/minetest-server
|
||||||
|
|
||||||
|
# user
|
||||||
|
USER="minetest"
|
||||||
|
|
||||||
|
# group
|
||||||
|
GROUP="minetest"
|
||||||
|
|
||||||
|
# pidfile
|
||||||
|
PIDFILE="/run/minetest-server.pid"
|
||||||
|
|
||||||
|
# executable
|
||||||
|
MINETESTBIN="/usr/bin/minetestserver"
|
||||||
|
|
||||||
|
# additional arguments for the server
|
||||||
|
ARGS="--logfile /var/log/minetest/minetest-server.log"
|
||||||
|
|
||||||
|
2. Edit or create the file `/etc/init.d/minetest-server`:
|
||||||
|
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
# Copyright 1999-2019 Gentoo Authors
|
||||||
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
supervisor="supervise-daemon"
|
||||||
|
|
||||||
|
description="Minetest dedicated server"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net postgresql-13 # Remove postgresql-13 if you don't use it as a Minetest backend.
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
ebegin "starting Minetest server"
|
||||||
|
${supervisor} ${RC_SVCNAME} \
|
||||||
|
--pidfile "${PIDFILE}" \
|
||||||
|
--user ${USER} \
|
||||||
|
--group ${GROUP} \
|
||||||
|
--start "${MINETESTBIN}" -- ${ARGS}
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "stopping Minetest server"
|
||||||
|
${supervisor} ${RC_SVCNAME} \
|
||||||
|
--stop \
|
||||||
|
--signal 15 \
|
||||||
|
--pidfile "${PIDFILE}" \
|
||||||
|
--user ${USER} \
|
||||||
|
--group ${GROUP}
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
3. Add the service to your default init level: `rc-update add minetest-server default`.
|
||||||
|
|
||||||
|
4. Start the service: `rc-service minetest-server start`.
|
||||||
|
|
||||||
|
5. Stop the service: `rc-service minetest-server stop`.
|
||||||
|
|
||||||
|
|
||||||
|
## TODO Use systemd to start/stop NALC as a daemon
|
||||||
|
|
||||||
|
|
||||||
|
# Update the server
|
||||||
|
|
||||||
|
You can execute the install.sh script again. If a nalc.conf file is detected in the specified destination, it will load all the settings specified during the previous installation.
|
||||||
|
Then you have to follow the instructions of the script and you will be able to update your server.
|
||||||
|
|
||||||
*Copyright: Sys4*
|
|
||||||
|
140
doc/README.org
Normal file
140
doc/README.org
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
* Description
|
||||||
|
The files to install the Minetest NALC server.
|
||||||
|
|
||||||
|
* Installation
|
||||||
|
Start the install.sh script and follow instructions.
|
||||||
|
|
||||||
|
Help: ./install.sh --help
|
||||||
|
|
||||||
|
* Requirements
|
||||||
|
|
||||||
|
- Official Minetest server must already be installed on your GNU/Linux system. If it is not the case, please refers to the https://minetest.net website for the installation instructions.
|
||||||
|
- You'll also need 'git', 'cmake' and 'make' programs installed.
|
||||||
|
|
||||||
|
* Examples of installation
|
||||||
|
|
||||||
|
** For a production server intended to be publicly available
|
||||||
|
We suppose that you have already installed Minetest server from your package manager.
|
||||||
|
|
||||||
|
The home of the 'minetest' user is located to /var/lib/minetest and you have the write access to it.
|
||||||
|
|
||||||
|
1. Create the dir '\/var/lib/minetest/.minetest' if not exist.
|
||||||
|
2. cd /var/lib/minetest
|
||||||
|
3. git clone --depth 1 -b master https://sys4.fr/gitea/nalc/nalc-server.git
|
||||||
|
4. cd nalc-server
|
||||||
|
5. ./install.sh -d \/var/lib/minetest/.minetest
|
||||||
|
6. Follow the instructions
|
||||||
|
|
||||||
|
** For a test server
|
||||||
|
We suppose you have already installed a production server that is actually in use and stable. But you want to install another one in palallel on the same system in order to test the development version of NALC.
|
||||||
|
|
||||||
|
For the next steps we will be logged in as a normal user:
|
||||||
|
|
||||||
|
1. cd
|
||||||
|
2. Create the dir '~/.minetest' if it not exist.
|
||||||
|
3. No need to download the server files again because they are already downloaded in the dir /var/lib/minetest/nalc-server. So you can just do a 'mkdir ~/nalc-dev'. But you can always do a 'git clone https://sys4.fr/gitea/nalc/nalc-server.git ~/nalc-dev' if you prefer. Whatever your choice and for the next steps we will refer to the install dir as '$INSTALL'.
|
||||||
|
4. $INSTALL/install.sh -d ~/.minetest -w test -P 30001 --branch dev ~/nalc-dev
|
||||||
|
5. Follow the instructions
|
||||||
|
|
||||||
|
** Case of a custom Minetest installation
|
||||||
|
We suppose you have compiled Minetest from sources with the CMAKE option RUN_IN_PLACE=TRUE. The location of your installation is ~/games/minetest.
|
||||||
|
|
||||||
|
1. cd ~/games
|
||||||
|
2. git clone https://sys4.fr/gitea/nalc/nalc-server.git
|
||||||
|
3. cd nalc-server
|
||||||
|
4. ./install.sh -b ~/games/minetest/bin/minetestserver -d ~/games/minetest
|
||||||
|
5. Follow the instructions
|
||||||
|
|
||||||
|
** Other cases
|
||||||
|
Other combinaisons are possibles and I cannot describe all of them. Don't hesitate to read the help of the script with --help option and do your own tests :)
|
||||||
|
|
||||||
|
* Add or disable mods
|
||||||
|
If you want to add mods you can do it easily. For that you can create the dir $DESTINATION/custom/mods where $DESTINATION is the dir where you have installed the server (the one containing the nalc.conf file).
|
||||||
|
Then copy your mods and modpacks in $DESTINATION/custom/mods and you need to execute $INSTALL/upgrade.sh -s $DESTINATION -w <world> -b <version> -f worldmt for regenerating the world.mt file of your world.
|
||||||
|
Replace <world> by your world name.
|
||||||
|
Replace <version> by the branch name specified during the installation, either 'stable', 'dev' or 'exp'.
|
||||||
|
|
||||||
|
If you want to disable mods you need to edit the file $DESTINATION/mods_disabled.txt and add one mod name per line.
|
||||||
|
Then execute again $INSTALL/upgrade.sh -s $DESTINATION -w <world> -b <version> -f worldmt.
|
||||||
|
|
||||||
|
Note: Depending on how you have installed NALC server, but $INSTALL and $DESTINATION can point to the same directory. If it's the case you can ommit the -s option.
|
||||||
|
|
||||||
|
* Start/Stop the server
|
||||||
|
** Use provided scripts
|
||||||
|
You can rename the $INSTALL/start.sh.example file to start.sh and give it executable permissions.
|
||||||
|
Then launch the server with the command $INSTALL/start.sh -s $DESTINATION.
|
||||||
|
|
||||||
|
Note: -s option can be ommited if you launch the script from the dir $DESTINATION.
|
||||||
|
|
||||||
|
For shutting down the server press CTRL-C.
|
||||||
|
|
||||||
|
You can edit the start.sh script for your needs.
|
||||||
|
|
||||||
|
** Use openrc to start/stop NALC as a daemon
|
||||||
|
We suppose minetest is installed from portage with the +server USE flag and NALC server is installed in the home of the minetest user ~/var/lib/minetest/nalc-server~. If you would use your Gentoo/Calculate Linux system init to start/stop NALC server as a service then you can follow theses steps:
|
||||||
|
|
||||||
|
1. Edit your ~/etc/conf.d/minetest-server~ file like that:
|
||||||
|
#+begin_src conf
|
||||||
|
# /etc/conf.d/minetest-server: config file for /etc/init.d/minetest-server
|
||||||
|
|
||||||
|
# user
|
||||||
|
USER="minetest"
|
||||||
|
|
||||||
|
# group
|
||||||
|
GROUP="minetest"
|
||||||
|
|
||||||
|
# pidfile
|
||||||
|
PIDFILE="/run/minetest-server.pid"
|
||||||
|
|
||||||
|
# executable
|
||||||
|
MINETESTBIN="/usr/bin/minetestserver"
|
||||||
|
|
||||||
|
# additional arguments for the server
|
||||||
|
ARGS="--logfile /var/log/minetest/minetest-server.log"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
2. Edit or create the file ~/etc/init.d/minetest-server~:
|
||||||
|
#+begin_src openrc-run
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
# Copyright 1999-2019 Gentoo Authors
|
||||||
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
supervisor="supervise-daemon"
|
||||||
|
|
||||||
|
description="Minetest dedicated server"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net postgresql-13 # Remove postgresql-13 if you don't use it as a Minetest backend.
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
ebegin "starting Minetest server"
|
||||||
|
${supervisor} ${RC_SVCNAME} \
|
||||||
|
--pidfile "${PIDFILE}" \
|
||||||
|
--user ${USER} \
|
||||||
|
--group ${GROUP} \
|
||||||
|
--start "${MINETESTBIN}" -- ${ARGS}
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "stopping Minetest server"
|
||||||
|
${supervisor} ${RC_SVCNAME} \
|
||||||
|
--stop \
|
||||||
|
--signal 15 \
|
||||||
|
--pidfile "${PIDFILE}" \
|
||||||
|
--user ${USER} \
|
||||||
|
--group ${GROUP}
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
3. Add the service to your default init level: ~rc-update add minetest-server default~.
|
||||||
|
|
||||||
|
4. Start the service: ~rc-service minetest-server start~.
|
||||||
|
|
||||||
|
5. Stop the service: ~rc-service minetest-server stop~.
|
||||||
|
** TODO Use systemd to start/stop NALC as a daemon
|
||||||
|
* Update the server
|
||||||
|
You can execute the install.sh script again. If a nalc.conf file is detected in the specified destination, it will load all the settings specified during the previous installation.
|
||||||
|
Then you have to follow the instructions of the script and you will be able to update your server.
|
682
install.sh
682
install.sh
@ -2,380 +2,468 @@
|
|||||||
# Author: Sys4
|
# Author: Sys4
|
||||||
# License: GPLv3
|
# License: GPLv3
|
||||||
|
|
||||||
# Fonctions
|
usage() {
|
||||||
|
echo "Usage: ./install_nalc.sh [options] [--] [destination]"
|
||||||
|
echo
|
||||||
|
echo "Description:"
|
||||||
|
echo -e "\tDownload and install the files needed by the NALC server to the"
|
||||||
|
echo -e "\toptional [destination] folder. Otherwise the current directory"
|
||||||
|
echo -e "\twill be used."
|
||||||
|
echo
|
||||||
|
echo -e "\tBut, be carefull!"
|
||||||
|
echo -e "\tBy default the ~/.minetest dir will also be used and modified."
|
||||||
|
echo -e "\tSo, make a backup of your ~/.minetest directory before the"
|
||||||
|
echo -e "\tinstallation of this server or specify a new directory with the"
|
||||||
|
echo -e "\t --minetest-dir or -d option."
|
||||||
|
echo
|
||||||
|
echo "Requirements:"
|
||||||
|
echo -e "\t- Official Minetest server must be already installed on your system."
|
||||||
|
echo -e "\tIf it is not the case, please refers to the https://minetest.net"
|
||||||
|
echo -e "\twebsite for the installation instructions."
|
||||||
|
echo -e "\t- You'll also need git, cmake, make."
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo -e "\t-h --help\t This help."
|
||||||
|
echo -e "\t-b --minetest-bin <path> Minetest server executable path."
|
||||||
|
echo -e "\t-d --minetest-dir <dir> Minetest directory to use for installing nalc mods, nalc game, minetest.conf…"
|
||||||
|
echo -e "\t-m --map-backend <sqlite3|leveldb|redis|postgresql|dummy>"
|
||||||
|
echo -e "\t-p --player-backend <sqlite3|leveldb|postgresql|dummy|files>"
|
||||||
|
echo -e "\t-a --auth-backend <sqlite3|leveldb|postgresql|files>"
|
||||||
|
echo -e "\t-M --minetest-mapper Install with minetest mapper support."
|
||||||
|
echo -e "\t-w --world <name> Custom world name."
|
||||||
|
echo -e "\t-P --port <port> Custom server port number."
|
||||||
|
echo -e "\t--url <URL> Custom remote URL."
|
||||||
|
echo -e "\t--branch <stable|dev|exp> Choose the version to install (stable by default)"
|
||||||
|
echo
|
||||||
|
echo "License: GPLv3. Please read the LICENSE file."
|
||||||
|
echo "Author: Sys4 - https://sys4.fr#contact"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
strip() {
|
strip() {
|
||||||
echo $1 | cut -d \' -f 2
|
echo $1 | cut -d \' -f 2
|
||||||
}
|
}
|
||||||
|
|
||||||
verif() {
|
verif() {
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo "Erreur ! Arrêt du script."
|
echo "Error! Exit."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
echo "ERREUR : Vérifiez vos paramètres !" >&2
|
if [[ -n $1 ]]; then
|
||||||
echo "Utilisez l'option -h pour en savoir plus" >&2
|
echo "ERROR: $1"! >&2
|
||||||
|
else
|
||||||
|
echo "ERROR: Invalid option!" >&2
|
||||||
|
echo "Use -h option for help." >&2
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
save_conf() {
|
||||||
echo "Usage: ./install.sh [options] [--] <version>"
|
local conf="$1"
|
||||||
echo "Options :"
|
echo "MINETEST_BIN=$MINETEST_BIN" > "$conf"
|
||||||
echo -e "\t-h --help\tAffiche l'aide."
|
echo "MINETEST_DIR=$MINETEST_DIR" >> "$conf"
|
||||||
echo -e "\t-j --makeopt\tNombre de threads de compilation."
|
echo "MAP_BACKEND=$MAP_BACKEND" >> "$conf"
|
||||||
echo -e "\t--ssh <user@host>: Identifiants ssh."
|
echo "PLAYER_BACKEND=$PLAYER_BACKEND" >> "$conf"
|
||||||
echo -e "\t--url <URL>: URL distante personnalisée."
|
echo "AUTH_BACKEND=$AUTH_BACKEND" >> "$conf"
|
||||||
echo -e "\t\tSi l'option --ssh est passée en option, il s'agira du chemin distant."
|
echo "MINETEST_MAPPER=$MINETEST_MAPPER" >> "$conf"
|
||||||
echo -e "\t-i --irrlicht\tChemin personnalisé des sources irrlicht."
|
echo "URL=$URL" >> "$conf"
|
||||||
echo -e "\t-p --postgresql\tSi vous voulez que le serveur soit configuré avec postgresql. Sinon leveldb par défaut."
|
echo "BRANCH=$BRANCH" >> "$conf"
|
||||||
echo "version :"
|
echo "WORLD_NAME=$WORLD_NAME" >> "$conf"
|
||||||
echo -e "\tstable : Installation du serveur compatible avec la dernière branche stable de minetest. Suivez les instructions... (Recommandé)"
|
echo "PORT=$PORT" >> "$conf"
|
||||||
echo -e "\tdev : Installation de la version en cours de developpement du serveur. Suivez les instructions... (Le plus à jour mais non Stable !)"
|
|
||||||
echo -e "\texperimental : Installation d'une version experimentale du serveur. Suivez les instructions... (Attention, très experimental !)"
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh() {
|
load_conf() {
|
||||||
ssh=$(strip $1)
|
. "$1"
|
||||||
echo "Installation avec identifiants ssh : $ssh"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url() {
|
install_game() {
|
||||||
url=$(strip $1)
|
local game_dir="$MINETEST_DIR/games/nalc_game"
|
||||||
}
|
if [ -d "$game_dir" ]; then
|
||||||
|
echo "Previous installation of NALC game detected."
|
||||||
makeopt() {
|
read -p "Upgrade? ([Y]es/[n]o/clean/[c]ancel) " continue
|
||||||
makeopt=$(strip $1)
|
case "$continue" in
|
||||||
}
|
[yY][eE][sS]|[yY]|"")
|
||||||
|
echo "Upgrading…"
|
||||||
postgresql() {
|
pushd "$game_dir"
|
||||||
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
|
|
||||||
read -p "Indiquez l'utilisateur de la BDD : " pg_user
|
|
||||||
read -p "Indiquez le mot de passe : " pg_password
|
|
||||||
read -p "Indiquez le nom de la BDD à utiliser : " pg_dbname
|
|
||||||
|
|
||||||
echo "gameid = nalc_game" > world.mt
|
|
||||||
echo "backend = postgresql" >> world.mt
|
|
||||||
echo "player_backend = postgresql" >> world.mt
|
|
||||||
echo "pgsql_connection = host=$pg_url user=$pg_user password=$pg_password dbname=$pg_dbname" >> world.mt
|
|
||||||
echo "pgsql_player_connection = host=$pg_url user=$pg_user password=$pg_password dbname=players-$pg_dbname" >> world.mt
|
|
||||||
echo "auth_backend = sqlite3" >> world.mt
|
|
||||||
}
|
|
||||||
|
|
||||||
install_minetest() {
|
|
||||||
if [[ -z $makeopt ]]; then
|
|
||||||
local makeopt=$(grep -c processor /proc/cpuinfo)
|
|
||||||
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
|
|
||||||
rm -rf minetest
|
|
||||||
echo "Répertoire minetest supprimé."
|
|
||||||
else
|
|
||||||
echo "Installation annulée. Fin"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
elif [[ $continue == "y" ]]; then
|
|
||||||
cd minetest
|
|
||||||
git pull
|
git pull
|
||||||
verif
|
verif
|
||||||
cd ..
|
popd;;
|
||||||
elif [[ $continue == "cancel" ]]; then
|
[cC][lL][eE][aA][nN])
|
||||||
echo "Installation annulée. Fin"
|
echo "Cleaning…"
|
||||||
exit 0
|
rm -rf "$game_dir"
|
||||||
fi
|
verif;;
|
||||||
|
[cC][aA][nN][cC][eE][lL]|[cC])
|
||||||
|
echo "Upgrade cancelled."
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
if [ ! -d "$game_dir" ]; then
|
||||||
|
local git_branch
|
||||||
|
local depth
|
||||||
|
case $BRANCH in
|
||||||
|
"stable")
|
||||||
|
git_branch="-b master"
|
||||||
|
depth="--depth 1"
|
||||||
|
;;
|
||||||
|
"dev")
|
||||||
|
git_branch="-b dev"
|
||||||
|
;;
|
||||||
|
"exp")
|
||||||
|
git_branch="-b experimental"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -z "$git_branch" ] && error "Invalid branch"
|
||||||
|
|
||||||
if [[ ! -d minetest ]]; then
|
echo "Cloning $URL""nalc/nalc_game.git to $game_dir…"
|
||||||
local branch="-b 5.4.1"
|
mkdir -p "$MINETEST_DIR/games"
|
||||||
|
verif
|
||||||
if [[ $ver == "dev" ]]; then
|
git clone $depth $git_branch $URL"nalc/nalc_game.git" "$game_dir"
|
||||||
branch="-b stable-5"
|
|
||||||
elif [[ $ver == "experimental" ]]; then
|
|
||||||
branch="-b master"
|
|
||||||
fi
|
|
||||||
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
|
verif
|
||||||
fi
|
fi
|
||||||
|
echo "NALC game installed/upgraded."
|
||||||
echo "Minetest va être (re)compilé..."
|
|
||||||
sleep 3
|
|
||||||
cd minetest
|
|
||||||
cmake . -DBUILD_CLIENT=0 -DBUILD_SERVER=1 -DENABLE_SOUND=0 -DENABLE_SYSTEM_GMP=1 $irrlicht_src -DENABLE_LEVELDB=1 -DENABLE_REDIS=1 -DENABLE_POSTGRESQL=1 -DRUN_IN_PLACE=1 -DENABLE_GETTEXT=1 -DENABLE_FREETYPE=1 -DENABLE_LUAJIT=1 -DENABLE_CURL=1
|
|
||||||
make -j$makeopt
|
|
||||||
verif
|
|
||||||
echo "Installation de Minetest terminé."
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
install_minetest_game() {
|
|
||||||
if [[ -d nalc_game ]]; then
|
|
||||||
echo "Installation précédente du jeux NALC détecté."
|
|
||||||
read -p "Mettre à jour ? (y,n,clean,cancel) " continue
|
|
||||||
if [[ $continue == "y" ]]; then
|
|
||||||
cd nalc_game
|
|
||||||
git pull
|
|
||||||
verif
|
|
||||||
cd ..
|
|
||||||
echo "Mise à jour du jeux NALC depuis dépôt distant terminé."
|
|
||||||
elif [[ $continue == "clean" ]]; then
|
|
||||||
echo "/!\ Cette action va effacer les données du répertoire nalc_game"
|
|
||||||
read -p "Êtes-vous sûr de vouloir continuer ? (y or n) " continue
|
|
||||||
if [[ $continue == "y" ]]; then
|
|
||||||
rm -rf nalc_game
|
|
||||||
echo "Jeux NALC 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 nalc_game ]]; then
|
|
||||||
local branch="-b master"
|
|
||||||
|
|
||||||
if [[ $ver == "dev" ]]; then
|
|
||||||
branch="-b dev"
|
|
||||||
elif [[ $ver == "experimental" ]]; then
|
|
||||||
branch="-b experimental"
|
|
||||||
fi
|
|
||||||
git clone --depth 1 $branch $URL/nalc_game.git
|
|
||||||
verif
|
|
||||||
echo "Clonage de nalc_game terminé."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -L minetest/games/nalc_game ]]; then
|
|
||||||
ln -s $(pwd)/nalc_game minetest/games/nalc_game
|
|
||||||
echo "Lien symbolique minetest/games/nalc_game vers $(pwd)/nalc_game créé."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Installation/Mise à jour du jeux NALC terminé."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_mods() {
|
install_mods() {
|
||||||
if [[ -d nalc-server-mods ]]; then
|
local mods_dir="$MINETEST_DIR/mods"
|
||||||
echo "Le dossier de mods est déjà présent. Que souhaitez-vous faire ?"
|
if [ -d "$mods_dir" ]; then
|
||||||
read -p "Choisissez parmi la liste, ([1]update, [2]clean update, [3]cancel, [4]Ne rien faire) : " continue
|
echo "Mods directory is not empty."
|
||||||
if [[ $continue == 1 ]]; then
|
read -p "Upgrade? ([Y]es/[n]o/clean/[c]ancel) " continue
|
||||||
./upgrade.sh -m
|
case "$continue" in
|
||||||
elif [[ $continue == 2 ]]; then
|
[yY][eE][sS]|[yY]|"")
|
||||||
rm -rf nalc-server-mods
|
echo "Upgrading…"
|
||||||
elif [[ $continue == 3 ]]; then
|
"$SCRIPT_DIR"/upgrade.sh -m -s "$DESTINATION"
|
||||||
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 == "experimental" ]]; then
|
|
||||||
branch="experimental"
|
|
||||||
fi
|
|
||||||
git clone --depth 1 -b $branch $URL/nalc-server-mods.git
|
|
||||||
verif
|
verif
|
||||||
./upgrade.sh -m
|
;;
|
||||||
|
[cC][lL][eE][aA][nN])
|
||||||
|
echo "Cleaning…"
|
||||||
|
rm -rf "$mods_dir"
|
||||||
|
verif
|
||||||
|
;;
|
||||||
|
[cC][aA][nN][cC][eE][lL]|[cC])
|
||||||
|
echo "Upgrade cancelled."
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
if [ ! -d "$mods_dir" ]; then
|
||||||
|
local git_branch
|
||||||
|
local depth
|
||||||
|
case $BRANCH in
|
||||||
|
"stable")
|
||||||
|
git_branch="-b master"
|
||||||
|
depth="--depth 1"
|
||||||
|
;;
|
||||||
|
"dev")
|
||||||
|
git_branch="-b dev"
|
||||||
|
;;
|
||||||
|
"exp")
|
||||||
|
git_branch="-b experimental"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -z $git_branch ] && error "Invalid branch"
|
||||||
|
|
||||||
if [[ -z $pg_dbname ]]; then
|
echo "Cloning $URL/nalc-server-mods.git to $mods_dir…"
|
||||||
cp worldmt-1.1.conf world.mt
|
git clone $depth $git_branch $URL"nalc/nalc-server-mods.git" "$mods_dir"
|
||||||
|
verif
|
||||||
|
pushd "$mods_dir"
|
||||||
|
git submodule update --init --recursive
|
||||||
|
verif
|
||||||
|
popd
|
||||||
fi
|
fi
|
||||||
|
echo "Mods for NALC installed/upgraded."
|
||||||
}
|
}
|
||||||
|
|
||||||
install_world() {
|
install_world() {
|
||||||
local world_name="nalc-$ver"
|
local world_dir="$MINETEST_DIR/worlds/$WORLD_NAME"
|
||||||
if [[ -n $pg_dbname ]]; then
|
if [ -d "$world_dir" ]; then
|
||||||
world_name=$pg_dbname
|
echo "$WORLD_NAME already exist."
|
||||||
|
read -p "Upgrade $WORLD_NAME? ([Y]es/[n]o/[c]lean) " continue
|
||||||
|
case "$continue" in
|
||||||
|
[yY][eE][sS]|[yY]|"")
|
||||||
|
echo "Upgrading…"
|
||||||
|
[ -d "$world_dir"_old ] && rm -rf "$world_dir"_old
|
||||||
|
cp -r "$world_dir" "$world_dir"_old
|
||||||
|
verif
|
||||||
|
;;
|
||||||
|
[cC][lL][eE][aA][nN]|[cC])
|
||||||
|
echo "Cleaning…"
|
||||||
|
[ -d "$world_dir"_old ] && rm -rf "$world_dir"_old
|
||||||
|
mv "$world_dir" "$world_dir"_old
|
||||||
|
verif
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
if [[ -d minetest/worlds/$world_name ]]; then
|
if [ ! -d "$world_dir" ]; then
|
||||||
echo "Une map est déjà présente. Que souhaitez-vous faire ?"
|
mkdir -p "$world_dir/runes"
|
||||||
read -p "Choisissez parmi la liste ([1]Nouveau, [2]Mettre à jour [3]Ne rien faire) : " continuer
|
verif
|
||||||
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
|
|
||||||
fi
|
|
||||||
# On sauvegarde l'ancien world
|
|
||||||
if [[ -d "minetest/worlds/"$world_name"_old" ]]; then
|
|
||||||
rm -rf "minetest/worlds/"$world_name"_old"
|
|
||||||
fi
|
|
||||||
mv minetest/worlds/$world_name "minetest/worlds/"$world_name"_old"
|
|
||||||
elif [[ $continuer == 2 ]]; then
|
|
||||||
# On sauvegarde l'ancien world
|
|
||||||
if [[ -d "minetest/worlds/"$world_name"_old" ]]; then
|
|
||||||
rm -rf "minetest/worlds/"$world_name"_old"
|
|
||||||
fi
|
|
||||||
cp -r minetest/worlds/$world_name "minetest/worlds/"$world_name"_old"
|
|
||||||
|
|
||||||
# On met à jour les fichiers contenues dans cette map
|
local mt=$world_dir/world.mt
|
||||||
./upgrade.sh -w $world_name -b $ver
|
echo "Generating $mt""…"
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d minetest/worlds/$world_name ]]; then
|
echo "gameid = nalc_game" > $mt
|
||||||
mkdir -p minetest/worlds/$world_name
|
echo "enable_damage = true" >> $mt
|
||||||
if [[ -n $pg_dbname ]]; then
|
echo "creative_mod = false" >> $mt
|
||||||
createdb $pg_dbname
|
case $MAP_BACKEND in
|
||||||
createdb players-$pg_dbname
|
"sqlite3"|"")
|
||||||
|
echo "backend = sqlite3" >> $mt
|
||||||
|
;;
|
||||||
|
"leveldb")
|
||||||
|
echo "backend = leveldb" >> $mt
|
||||||
|
;;
|
||||||
|
"redis")
|
||||||
|
echo "backend = redis" >> $mt
|
||||||
|
read -p "redis_address? " val
|
||||||
|
echo "redis_address = $val" >> $mt
|
||||||
|
read -p "redis_hash? " val
|
||||||
|
echo "redis_hash = $val" >> $mt
|
||||||
|
read -p "redis_port? (6379) " val
|
||||||
|
[ -z $val ] && val=6379
|
||||||
|
echo "redis_port = $val" >> $mt
|
||||||
|
;;
|
||||||
|
"postgresql")
|
||||||
|
echo "backend = postgresql" >> $mt
|
||||||
|
read -p "DB address? " val
|
||||||
|
read -p "DB user? " val2
|
||||||
|
read -p "DB password? " val3
|
||||||
|
read -p "DB name? " val4
|
||||||
|
read -p "DB port? (5432) " val5
|
||||||
|
[ -z $val5 ] && val5=5432
|
||||||
|
echo "pgsql_connection = host=$val port=$val5 user=$val2 password=$val3 dbname=$val4" >> $mt
|
||||||
|
;;
|
||||||
|
"dummy")
|
||||||
|
echo "backend = dummy" >> $mt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$MAP_BACKEND is not valid";;
|
||||||
|
esac
|
||||||
|
case $PLAYER_BACKEND in
|
||||||
|
"sqlite3"|"")
|
||||||
|
echo "player_backend = sqlite3" >> $mt
|
||||||
|
;;
|
||||||
|
"leveldb")
|
||||||
|
echo "player_backend = leveldb" >> $mt
|
||||||
|
;;
|
||||||
|
"postgresql")
|
||||||
|
echo "player_backend = postgresql" >> $mt
|
||||||
|
read -p "DB address? ($val) " vval
|
||||||
|
read -p "DB user? ($val2) " vval2
|
||||||
|
read -p "DB password? ($val3) " vval3
|
||||||
|
read -p "DB name? (players-$val4) " vval4
|
||||||
|
read -p "DB port? ($val5) " vval5
|
||||||
|
[ -z $vval ] && vval=$val
|
||||||
|
[ -z $vval2 ] && vval2=$val2
|
||||||
|
[ -z $vval3 ] && vval3=$val3
|
||||||
|
[ -z $vval4 ] && vval4="players-$val4"
|
||||||
|
[ -z $vval5 ] && vval5=$val5
|
||||||
|
echo "pgsql_player_connection = host=$vval port=$vval5 user=$vval2 password=$vval3 dbname=$vval4" >> $mt
|
||||||
|
;;
|
||||||
|
"dummy")
|
||||||
|
echo "player_backend = dummy" >> $mt
|
||||||
|
;;
|
||||||
|
"files")
|
||||||
|
echo "player_backend = files" >> $mt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$PLAYER_BACKEND is not valid";;
|
||||||
|
esac
|
||||||
|
case $AUTH_BACKEND in
|
||||||
|
"sqlite3"|"")
|
||||||
|
echo "auth_backend = sqlite3" >> $mt
|
||||||
|
;;
|
||||||
|
"leveldb")
|
||||||
|
echo "auth_backend = leveldb" >> $mt
|
||||||
|
;;
|
||||||
|
"postgresql")
|
||||||
|
echo "auth_backend = postgresql" >> $mt
|
||||||
|
read -p "DB address? ($val) " vval
|
||||||
|
read -p "DB user? ($val2) " vval2
|
||||||
|
read -p "DB password? ($val3) " vval3
|
||||||
|
read -p "DB name? (auth-$val4) " vval4
|
||||||
|
read -p "DB port? ($val5) " vval5
|
||||||
|
[ -z $vval ] && vval=$val
|
||||||
|
[ -z $vval2 ] && vval2=$val2
|
||||||
|
[ -z $vval3 ] && vval3=$val3
|
||||||
|
[ -z $vval4 ] && vval4="auth-$val4"
|
||||||
|
[ -z $vval5 ] && vval5=$val5
|
||||||
|
echo "pgsql_auth_connection = host=$vval port=$vval5 user=$vval2 password=$vval3 dbname=$vval4" >> $mt
|
||||||
|
;;
|
||||||
|
"files")
|
||||||
|
echo "auth_backend = files" >> $mt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$AUTH_BACKEND is not valid";;
|
||||||
|
esac
|
||||||
|
read -p "Server announce? (y/N) " val
|
||||||
|
if [[ $val =~ [yY][eE][sS]|[yY] ]]; then
|
||||||
|
echo "server_announce = true" >> $mt
|
||||||
|
else
|
||||||
|
echo "server_announce = false" >> $mt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./upgrade.sh -w $world_name -b $ver
|
|
||||||
|
|
||||||
mkdir -p minetest/worlds/$world_name/runes
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
post_install() {
|
|
||||||
if [[ ! -a minetest/minetest.conf ]]; then
|
|
||||||
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
|
|
||||||
|
|
||||||
if [[ ! -d logs ]]; then
|
|
||||||
mkdir logs
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -a start.sh ]]; then
|
|
||||||
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"
|
|
||||||
echo ""
|
|
||||||
echo "Pour utiliser la génération de la carte, installer ImageMagick avec la dépendance fontconfig et truetype."
|
|
||||||
echo "Il faudra aussi autoriser lecture et écriture pour PS. Dans le fichier de gestion de la police de sécurité d'ImageMagick."
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_mtmapper() {
|
install_mtmapper() {
|
||||||
if [ -n $ssh ]; then
|
if [ ! -d "$DESTINATION/minetestmapper" ]; then
|
||||||
URL=$ssh\:minetest
|
echo "Clone Minetest mapper…"
|
||||||
else
|
git clone --depth 1 $URL"/minetest/minetestmapper.git" "$DESTINATION/minetestmapper"
|
||||||
URL="https://sys4.fr/gitea/minetest"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$(pwd)/minetestmapper" ]; then
|
|
||||||
git clone --depth 1 $URL/minetestmapper.git
|
|
||||||
verif
|
verif
|
||||||
|
else
|
||||||
|
echo "Upgrading Minetest mapper…"
|
||||||
|
pushd "$DESTINATION/minetestmapper"
|
||||||
|
git pull
|
||||||
|
verif
|
||||||
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "$(pwd)/minetestmapper"
|
pushd "$DESTINATION/minetestmapper"
|
||||||
git pull
|
|
||||||
cmake .
|
cmake .
|
||||||
[ $? -eq 1 ] && echo "Vérifier les dépendances de minetestmapper puis recompiler."
|
[ $? -eq 1 ] && error "CMake failed. Check dependencies"
|
||||||
make -j$makeopt
|
make -j$(nproc)
|
||||||
|
verif
|
||||||
popd
|
popd
|
||||||
|
|
||||||
if [ -n $ssh ]; then
|
if [ ! -d "$DESTINATION/leaftest" ]; then
|
||||||
URL=$ssh\:nalc
|
echo "Installing leaftest…"
|
||||||
else
|
git clone --recursive --depth 1 $URL"nalc/leaftest.git" "$DESTINATION/leaftest"
|
||||||
URL="https://sys4.fr/gitea/nalc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$(pwd)/leaftest" ]; then
|
|
||||||
git clone --recursive --depth 1 $URL/leaftest.git
|
|
||||||
verif
|
verif
|
||||||
|
else
|
||||||
|
echo "Upgrading leaftest…"
|
||||||
|
pushd "$DESTINATION/leaftest"
|
||||||
|
git pull
|
||||||
|
verif
|
||||||
|
popd
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
post_install() {
|
||||||
ver=$(strip $1)
|
if [[ "$DESTINATION" != "$SCRIPT_DIR" ]]; then
|
||||||
|
cp "$SCRIPT_DIR/mods_disabled.txt" "$DESTINATION"
|
||||||
if [[ -n $ssh && -n $url ]]; then
|
|
||||||
URL=$ssh\:$url
|
|
||||||
elif [[ -n $url ]]; then
|
|
||||||
URL=$url
|
|
||||||
else
|
|
||||||
URL="https://sys4.fr/gitea/nalc"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "L'installation va démarrer. Continuer ? (y or n) : " continue
|
"$SCRIPT_DIR"/upgrade.sh -w $WORLD_NAME -b $BRANCH -s "$DESTINATION"
|
||||||
if [[ $continue == "y" ]]; then
|
"$SCRIPT_DIR"/upgrade.sh -w $WORLD_NAME -b $BRANCH -f mtconf -s "$DESTINATION"
|
||||||
install_minetest
|
|
||||||
install_minetest_game
|
echo "Please, review and edit the following files:"
|
||||||
install_mods
|
echo -e "\t- $MINETEST_DIR/minetest.conf"
|
||||||
install_world
|
echo -e "\t- $DESTINATION/mods_disabled.txt"
|
||||||
install_mtmapper
|
echo
|
||||||
post_install
|
|
||||||
echo "L'installation est terminé. Bravo !"
|
if [ $MINETEST_MAPPER -eq 1 ]; then
|
||||||
else
|
echo "The use of Minetest Mapper needs ImageMagick with fontconfig and truetype dependencies."
|
||||||
echo "Installation annulée. Fin."
|
echo "You also need to allow read and write permissions for PS. The configuration can be found in the file that manage the security policy of ImageMagick."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
action() {
|
action() {
|
||||||
local arg=$(strip $1)
|
echo "Preparing the installation…"
|
||||||
if [[ $arg == "dev" || $arg == "stable" || $arg == "experimental" ]]; then
|
|
||||||
init $arg
|
DESTINATION="$1"
|
||||||
else
|
GIT=$(which git)
|
||||||
error
|
CMAKE=$(which cmake)
|
||||||
|
MAKE=$(which make)
|
||||||
|
[ ! -e "$GIT" ] && error "git not found"
|
||||||
|
[ ! -e "$CMAKE" ] && error "cmake not found"
|
||||||
|
[ ! -e "$MAKE" ] && error "make not found"
|
||||||
|
|
||||||
|
if [ -e "$DESTINATION/nalc.conf" ]; then
|
||||||
|
read -p "Previous installation is detected. Do you want to load previous settings? [Y/n] " continue
|
||||||
|
if [ -z $continue ] || [[ "$continue" =~ ^[yY][eE][sS]|[yY]$ ]]; then
|
||||||
|
load_conf "$DESTINATION/nalc.conf"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z $MINETEST_BIN ] && MINETEST_BIN=$(which minetestserver)
|
||||||
|
[ -z $MINETEST_DIR ] && MINETEST_DIR=~/.minetest
|
||||||
|
[ -z $MAP_BACKEND ] && MAP_BACKEND=sqlite3
|
||||||
|
[ -z $PLAYER_BACKEND ] && PLAYER_BACKEND=sqlite3
|
||||||
|
[ -z $AUTH_BACKEND ] && AUTH_BACKEND=sqlite3
|
||||||
|
[ -z $MINETEST_MAPPER ] && MINETEST_MAPPER=0
|
||||||
|
[ -z $PORT ] && PORT=30000
|
||||||
|
[ -z $URL ] && URL="https://sys4.fr/gitea/"
|
||||||
|
[[ $URL =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+$ ]] && URL="$URL:"
|
||||||
|
[ -z $BRANCH ] && BRANCH="stable"
|
||||||
|
[ -z $WORLD_NAME ] && WORLD_NAME="nalc"
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||||
|
[ -z $DESTINATION ] && DESTINATION="$SCRIPT_DIR"
|
||||||
|
[ ! -e $MINETEST_BIN ] && error "$MINETEST_BIN not found"
|
||||||
|
[ ! -d $MINETEST_DIR ] && error "$MINETEST_DIR not found"
|
||||||
|
|
||||||
|
|
||||||
|
echo "Installation summary:"
|
||||||
|
echo -e "\t- Server files will be downloaded from $URL"
|
||||||
|
echo -e "\t- NALC server will be installed to $DESTINATION."
|
||||||
|
echo -e "\t- World of NALC will be installed to $MINETEST_DIR/worlds/$WORLD_NAME"
|
||||||
|
echo -e "\t- The minetestserver executable $MINETEST_BIN will be used."
|
||||||
|
echo -e "\t- The $MINETEST_DIR directory will be used."
|
||||||
|
echo -e "\t- $MAP_BACKEND will be used as map backend."
|
||||||
|
echo -e "\t- $PLAYER_BACKEND will be used as player backend."
|
||||||
|
echo -e "\t- $AUTH_BACKEND will be used as auth backend."
|
||||||
|
echo -e "\t- Port used: $PORT."
|
||||||
|
[ $MINETEST_MAPPER -eq 1 ] && echo -e "\t- Minetest mapper support added."
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -p "Installation of NALC server will begin. Continue? [Y/n] " continue
|
||||||
|
if [ -z $continue ] || [[ "$continue" =~ ^[yY][eE][sS]|[yY]$ ]]; then
|
||||||
|
save_conf "$DESTINATION/nalc.conf"
|
||||||
|
install_game
|
||||||
|
install_mods
|
||||||
|
install_world
|
||||||
|
[ $MINETEST_MAPPER -eq 1 ] && install_mtmapper
|
||||||
|
post_install
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "End of the NALC server installation. Good Bye!"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
irrlicht() {
|
[ $# -lt 0 ] && usage
|
||||||
local arg=$(strip $1)
|
|
||||||
if [[ -d $arg ]]; then
|
|
||||||
irrlicht_src="-DIRRLICHT_SOURCE_DIR=$arg"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Pas de paramètre
|
OPT=$(getopt -o h,b:,d:,m:,p:,a:,M,w:,P: -l help,minetest-bin:,minetest-dir:,map-backend:,player-backend:,auth-backend:,minetest-mapper,url:,branch:,world:,port: -- "$@")
|
||||||
#[[ $# -lt 1 ]] && error
|
|
||||||
# ou
|
|
||||||
[[ $# -lt 1 ]] && usage
|
|
||||||
|
|
||||||
# -o : Options courtes
|
|
||||||
# -l : options longues
|
|
||||||
OPT=$(getopt -o h,p,j:,i: -l help,postgresql,url:,ssh:,makeopt:,irrlicht: -- "$@")
|
|
||||||
|
|
||||||
# éclatement de $options en $1, $2...
|
|
||||||
set -- $OPT
|
set -- $OPT
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage;;
|
usage;;
|
||||||
-i|--irrlicht)
|
-b|--minetest-bin)
|
||||||
irrlicht $2
|
MINETEST_BIN=$(strip "$2")
|
||||||
shift 2;;
|
shift 2;;
|
||||||
-p|--postgresql)
|
-d|--minetest-dir)
|
||||||
postgresql
|
MINETEST_DIR=$(strip "$2")
|
||||||
shift;;
|
shift 2;;
|
||||||
--ssh)
|
-m|--map-backend)
|
||||||
ssh $2
|
MAP_BACKEND=$(strip "$2")
|
||||||
|
shift 2;;
|
||||||
|
-p|--player-backend)
|
||||||
|
PLAYER_BACKEND=$(strip "$2")
|
||||||
|
shift 2;;
|
||||||
|
-a|--auth-backend)
|
||||||
|
AUTH_BACKEND=$(strip "$2")
|
||||||
|
shift 2;;
|
||||||
|
-M|--minetest-mapper)
|
||||||
|
MINETEST_MAPPER=1
|
||||||
|
shift 1;;
|
||||||
|
-w|--world)
|
||||||
|
WORLD_NAME=$(strip "$2")
|
||||||
|
shift 2;;
|
||||||
|
-P|--port)
|
||||||
|
PORT=$(strip $2)
|
||||||
shift 2;;
|
shift 2;;
|
||||||
--url)
|
--url)
|
||||||
url $2
|
URL=$(strip "$2")
|
||||||
shift 2;;
|
shift 2;;
|
||||||
-j|--makeopt)
|
--branch)
|
||||||
makeopt $2
|
BRANCH=$(strip "$2")
|
||||||
shift 2;;
|
shift 2;;
|
||||||
--)
|
--)
|
||||||
shift;;
|
shift;;
|
||||||
*)
|
*)
|
||||||
action $1
|
action $(strip "$1")
|
||||||
shift;;
|
shift;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1,29 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This is a startup script example you can adapt for your needs.
|
||||||
|
# It can take a server directory to start as argument else,
|
||||||
|
# it will use the current dir.
|
||||||
|
# If you want to use it, rename it to 'start.sh' and give it executable rights.
|
||||||
|
#
|
||||||
|
# If you want to start/stop the server as a system service you should not use this
|
||||||
|
# script. Please read the documentation for more informations.
|
||||||
|
#
|
||||||
|
|
||||||
serverpath=/home/minetest/nalc-server
|
serverdir="$1"
|
||||||
world=$serverpath/minetest/worlds/nalc
|
[ -z "$serverdir" ] && serverdir="$(pwd)"
|
||||||
|
if [ ! -e "$serverdir/nalc.conf" ]; then
|
||||||
|
echo "ERROR: nalc.conf not found!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
. "$serverdir/nalc.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
DEBUG=$serverpath/logs/debug.log
|
#DEBUG=$serverdir/logs/debug.log
|
||||||
MOREDEBUG=$serverpath/logs/moredebug.log
|
#MOREDEBUG=$serverdir/logs/moredebug.log
|
||||||
|
|
||||||
cd $serverpath/minetest/bin
|
#while true; do
|
||||||
|
# sleep 5
|
||||||
while true
|
# echo "----------------------" >>$MOREDEBUG
|
||||||
do
|
# echo "Server restarted at "`date` >>$MOREDEBUG
|
||||||
sleep 5
|
# echo "----------------------" >>$MOREDEBUG
|
||||||
|
|
||||||
echo "----------------------" >>$MOREDEBUG
|
|
||||||
echo "Server restarted at "`date` >>$MOREDEBUG
|
|
||||||
echo "----------------------" >>$MOREDEBUG
|
|
||||||
|
|
||||||
echo "0" >/tmp/players_c.txt
|
echo "0" >/tmp/players_c.txt
|
||||||
|
|
||||||
./minetestserver \
|
"$MINETEST_BIN" \
|
||||||
--world $world/ \
|
--world "$MINETEST_DIR/worlds/$WORLD_NAME/" \
|
||||||
--config $serverpath/minetest/minetest.conf \
|
--config "$MINETEST_DIR/minetest.conf" \
|
||||||
--gameid nalc_game \
|
--gameid nalc_game \
|
||||||
--port 30002 \
|
--port $PORT \
|
||||||
# --logfile $DEBUG
|
# --logfile $DEBUG
|
||||||
|
|
||||||
sleep 25
|
#done &>> $MOREDEBUG
|
||||||
done &>> $MOREDEBUG
|
|
||||||
|
121
upgrade.sh
121
upgrade.sh
@ -2,7 +2,8 @@
|
|||||||
# Author: Sys4
|
# Author: Sys4
|
||||||
# License: GPLv3
|
# License: GPLv3
|
||||||
|
|
||||||
serverpath=$(pwd)
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||||
|
serverpath="$SCRIPT_DIR"
|
||||||
UP_MODS=0
|
UP_MODS=0
|
||||||
WORLD_FILE=all
|
WORLD_FILE=all
|
||||||
|
|
||||||
@ -58,16 +59,16 @@ usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
regen_worldmt() {
|
regen_worldmt() {
|
||||||
local worldfile=$serverpath/world.mt
|
local worldfile="$MINETEST_DIR/worlds/$WORLD_NAME/world.mt"
|
||||||
|
|
||||||
echo "Regénération du fichier $worldfile..."
|
echo "Regénération du fichier $worldfile..."
|
||||||
|
|
||||||
# Faire une sauvegarde du fichier world.mt actuel
|
# Faire une sauvegarde du fichier world.mt actuel
|
||||||
cp $worldfile $serverpath/world.mt.bak
|
cp "$worldfile" "$worldfile".bak
|
||||||
|
|
||||||
# Créer un nouveau fichier temporaire sans les lignes commençant par load_mod
|
# Créer un nouveau fichier temporaire sans les lignes commençant par load_mod
|
||||||
local i=0
|
local i=0
|
||||||
cat $worldfile | while read -r line; do
|
cat "$worldfile" | while read -r line; do
|
||||||
local match=$(echo $line | grep load_mod_)
|
local match=$(echo $line | grep load_mod_)
|
||||||
if [[ -z $match ]]; then
|
if [[ -z $match ]]; then
|
||||||
if [[ $i -eq 0 ]]; then
|
if [[ $i -eq 0 ]]; then
|
||||||
@ -83,52 +84,39 @@ regen_worldmt() {
|
|||||||
# Recréation des liens symboliques des mods dans le dossier minetest
|
# Recréation des liens symboliques des mods dans le dossier minetest
|
||||||
# et générer une ligne "load_mod_<mod> = true ou false" pour chaque mod
|
# et générer une ligne "load_mod_<mod> = true ou false" pour chaque mod
|
||||||
# et l'ajouter au fichier
|
# et l'ajouter au fichier
|
||||||
|
# local mods_path=$serverpath/nalc-server-mods
|
||||||
|
local mods="$MINETEST_DIR/mods"
|
||||||
|
local mods_custom="$serverpath/custom/mods"
|
||||||
|
|
||||||
local mods_path=$serverpath/nalc-server-mods
|
# Suppression d'éventuels liens symboliques du dossier des mods
|
||||||
local mods_minetest=$serverpath/minetest/mods
|
ls "$mods" | while read -r mod; do
|
||||||
local mods_custom=$serverpath/custom/mods
|
[ -L "$mods/$mod" ] && rm -f "$mods/$mod"
|
||||||
|
done
|
||||||
|
|
||||||
rm -f $mods_minetest/*
|
if [ -d "$mods_custom" ]; then
|
||||||
|
|
||||||
if [[ -d $mods_custom ]]; then
|
|
||||||
ls $mods_custom | while read -r mod; do
|
ls $mods_custom | while read -r mod; do
|
||||||
if [[ -d $mods_custom/$mod ]]; then
|
[ -d $mods_custom/$mod ] && ln -s $mods_custom/$mod $mods/$mod
|
||||||
rm -f $mods_path/$mod
|
|
||||||
ln -s $mods_custom/$mod $mods_path/$mod
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Liste des mods à désactiver
|
# Liste des mods à désactiver
|
||||||
local mods="3d_armor_ip 3d_armor_sfinv 3dmushrooms"
|
readarray -t md < "$serverpath/mods_disabled.txt"
|
||||||
|
|
||||||
local md[1]=""
|
# Populate world.mt
|
||||||
local i=0
|
ls "$mods" | while read -r mod; do
|
||||||
for mod in $mods; do
|
if [ -d $mods/$mod ]; then
|
||||||
i=$(( $i+1 ))
|
if [ -e $mods/$mod/init.lua ]; then
|
||||||
md[$i]=$mod
|
|
||||||
done
|
|
||||||
|
|
||||||
ls $mods_path | while read -r mod; do
|
|
||||||
if [[ -d $mods_path/$mod ]]; then
|
|
||||||
ln -s $mods_path/$mod $mods_minetest/$mod
|
|
||||||
|
|
||||||
if [[ -e $mods_path/$mod/init.lua ]]; then
|
|
||||||
local mod_enable="true"
|
local mod_enable="true"
|
||||||
for (( modn=1; modn<=$i; modn++ )); do
|
for (( modn=0; modn<${#md[@]}; modn++ )); do
|
||||||
if [[ ${md[$modn]} == $mod ]]; then
|
[ ${md[$modn]} == $mod ] && mod_enable="false"
|
||||||
mod_enable="false"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "load_mod_$mod = $mod_enable" >> /tmp/world.mt
|
echo "load_mod_$mod = $mod_enable" >> /tmp/world.mt
|
||||||
else
|
else
|
||||||
ls $mods_path/$mod | while read -r submod; do
|
ls "$mods/$mod" | while read -r submod; do
|
||||||
if [[ -d $mods_path/$mod/$submod ]]; then
|
if [ -d "$mods/$mod/$submod" ]; then
|
||||||
local mod_enable="true"
|
local mod_enable="true"
|
||||||
for (( modn=1; modn<=$i; modn++ )); do
|
for (( modn=0; modn<${#md[@]}; modn++ )); do
|
||||||
if [[ ${md[$modn]} == $submod ]]; then
|
[ ${md[$modn]} == $submod ] && mod_enable="false"
|
||||||
mod_enable="false"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "load_mod_$submod = $mod_enable" >> /tmp/world.mt
|
echo "load_mod_$submod = $mod_enable" >> /tmp/world.mt
|
||||||
fi
|
fi
|
||||||
@ -138,18 +126,16 @@ regen_worldmt() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Remplacement du l'ancien world.mt par le nouveau
|
# Remplacement du l'ancien world.mt par le nouveau
|
||||||
mv /tmp/world.mt $serverpath/world.mt
|
mv /tmp/world.mt "$MINETEST_DIR/worlds/$WORLD_NAME/world.mt"
|
||||||
|
|
||||||
echo "Regénération terminé."
|
echo "Regénération terminé."
|
||||||
}
|
}
|
||||||
|
|
||||||
update_mods() {
|
update_mods() {
|
||||||
local mods_path=$serverpath/nalc-server-mods
|
local mods_path="$MINETEST_DIR/mods"
|
||||||
if [[ ! -d $mods_path ]]; then
|
[ ! -d "$mods_path" ] && error "$mods_path not found"
|
||||||
error "Le répertoire $mods_path n'existe pas"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd $mods_path > /dev/null 2>&1
|
pushd "$mods_path" > /dev/null 2>&1
|
||||||
git pull
|
git pull
|
||||||
verif
|
verif
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
@ -158,17 +144,17 @@ update_mods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_world() {
|
update_world() {
|
||||||
local world_repos=$serverpath/world
|
local world_repos="$SCRIPT_DIR/world"
|
||||||
local world_dest=$serverpath/minetest/worlds/$WORLD_NAME
|
local world_dest="$MINETEST_DIR/worlds/$WORLD_NAME"
|
||||||
|
|
||||||
if [[ ! -d $world_repos ]]; then
|
if [ ! -d "$world_repos" ]; then
|
||||||
error "$world_repos n'existe pas"
|
error "$world_repos not found"
|
||||||
fi
|
fi
|
||||||
if [[ ! -d $world_dest ]]; then
|
if [ ! -d "$world_dest" ]; then
|
||||||
error "$world_dest n'existe pas"
|
error "$world_dest not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WORLD_FILE == "all" ]]; then
|
if [ $WORLD_FILE == "all" ]; then
|
||||||
WORLD_FILE="moretrees news technic fbn fbnp bitchange christmas randommsg worldmt"
|
WORLD_FILE="moretrees news technic fbn fbnp bitchange christmas randommsg worldmt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -203,20 +189,16 @@ update_world() {
|
|||||||
file=$world_repos/random_messages-$BRANCH;;
|
file=$world_repos/random_messages-$BRANCH;;
|
||||||
worldmt)
|
worldmt)
|
||||||
do_copy=0
|
do_copy=0
|
||||||
regen_worldmt
|
regen_worldmt;;
|
||||||
rm -f $world_dest/world.mt
|
|
||||||
ln -s $serverpath/world.mt $world_dest/world.mt;;
|
|
||||||
mtconf) # Exception ici car n'est pas un fichier world. Doit être appelé seul.
|
mtconf) # Exception ici car n'est pas un fichier world. Doit être appelé seul.
|
||||||
file_dest=$serverpath/minetest/minetest.conf
|
file_dest="$MINETEST_DIR/minetest.conf"
|
||||||
file=$serverpath/minetest-$BRANCH.conf;;
|
file="$SCRIPT_DIR/minetest-$BRANCH.conf";;
|
||||||
*)
|
*)
|
||||||
error;;
|
error;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $do_copy -eq 1 ]]; then
|
if [ $do_copy -eq 1 ]; then
|
||||||
if [[ ! -e $file ]]; then
|
[ ! -e $file ] && error "Le fichier $file n'existe pas"
|
||||||
error "Le fichier $file n'existe pas"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Copie de $file vers $file_dest"
|
echo "Copie de $file vers $file_dest"
|
||||||
cp -up $file $file_dest
|
cp -up $file $file_dest
|
||||||
@ -225,21 +207,22 @@ update_world() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action() {
|
action() {
|
||||||
if [[ ! -d $serverpath ]]; then
|
[ ! -d "$serverpath" ] && error "$serverpath not found"
|
||||||
error "Le répertoire $serverpath n'existe pas"
|
. "$serverpath/nalc.conf"
|
||||||
fi
|
[[ $BRANCH == "exp" ]] && BRANCH="experimental"
|
||||||
|
|
||||||
if [[ $UP_MODS -eq 1 ]]; then
|
if [ $UP_MODS -eq 1 ]; then
|
||||||
echo "Mise à jour des mods dans $serverpath/nalc-server-mods..."
|
echo "Updating $MINETEST_DIR/mods…"
|
||||||
update_mods
|
update_mods
|
||||||
echo "Mise à jour des mods terminé."
|
echo "Mods updated."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $WORLD_NAME && -n $BRANCH ]]; then
|
if [ -n $WORLD_NAME ] && [ -n $BRANCH ]; then
|
||||||
echo "Mise à jour de $WORLD_FILE dans $serverpath/minetest/worlds/$WORLD_NAME de la branche $BRANCH..."
|
echo "Updating $WORLD_FILE from $WORLD_NAME and branch $BRANCH"…
|
||||||
update_world
|
update_world
|
||||||
echo "Mise à jour des fichiers world terminé."
|
echo "World files updated."
|
||||||
elif [[ -n $WORLD_NAME || -n $BRANCH ]]; then
|
elif [ -n $WORLD_NAME ] || [ -n $BRANCH ]; then
|
||||||
error
|
error
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user