2017-06-09 14:03:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# GENERIC START
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2019-10-26 22:42:12 +02:00
|
|
|
source _common.sh
|
2020-06-07 10:47:21 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# MANAGE SCRIPT FAILURE
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_clean_setup () {
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_clean_check_starting
|
2019-10-24 04:11:14 +02:00
|
|
|
}
|
2019-04-21 15:32:30 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_abort_if_errors
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
#REMOVEME? game=$YNH_APP_ARG_GAME
|
|
|
|
#REMOVEME? servername=$YNH_APP_ARG_SERVERNAME
|
|
|
|
#REMOVEME? pvp=$YNH_APP_ARG_PVP
|
|
|
|
#REMOVEME? creative=$YNH_APP_ARG_CREATIVE
|
|
|
|
#REMOVEME? damage=$YNH_APP_ARG_DAMAGE
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
|
|
|
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
2021-05-16 18:15:51 +02:00
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
2020-07-29 22:11:02 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=game --value=$game
|
2022-06-19 04:22:13 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=servername --value=$servername
|
2019-04-21 15:32:30 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=pvp --value=$pvp
|
|
|
|
ynh_app_setting_set --app=$app --key=creative --value=$creative
|
|
|
|
ynh_app_setting_set --app=$app --key=damage --value=$damage
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
#=================================================
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Finding an available port..."
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2021-05-16 18:15:51 +02:00
|
|
|
# Find an available port
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? port=$(ynh_find_port 30000)
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
|
2022-06-19 04:22:13 +02:00
|
|
|
|
2021-05-16 18:15:51 +02:00
|
|
|
# Open the port
|
|
|
|
ynh_script_progression --message="Configuring firewall..."
|
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp UDP $port
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
2019-04-21 15:32:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Configuring system user..."
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2019-10-25 01:55:03 +02:00
|
|
|
# Create a system user
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
2021-05-16 18:15:51 +02:00
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
2021-05-16 18:15:51 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-08 13:13:58 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-05-16 18:15:51 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2021-05-16 18:15:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2022-06-19 04:22:13 +02:00
|
|
|
# CREATE DATA DIRECTORY
|
2021-05-16 18:15:51 +02:00
|
|
|
#=================================================
|
2022-06-19 04:22:13 +02:00
|
|
|
ynh_script_progression --message="Creating a data directory..."
|
2019-08-15 14:21:00 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? data_dir=/home/yunohost.app/$app
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
mkdir -p $data_dir
|
|
|
|
mkdir -p "$data_dir/.minetest/worlds/"
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
chmod 750 "$data_dir"
|
|
|
|
chmod -R o-rwx "$data_dir"
|
|
|
|
chown -R $app:www-data "$data_dir"
|
2019-04-21 15:32:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
# BUILDING
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Building Minetest..."
|
|
|
|
|
2021-05-18 03:14:18 +02:00
|
|
|
# Install the game
|
|
|
|
if [ $game = "capturetheflag" ]; then
|
2024-01-08 13:13:58 +01:00
|
|
|
pushd $install_dir
|
2021-05-16 18:15:51 +02:00
|
|
|
git clone --recursive https://github.com/MT-CTF/capturetheflag.git games/capturetheflag
|
2021-05-18 03:14:18 +02:00
|
|
|
popd
|
|
|
|
else
|
|
|
|
# Download Minetest Game
|
2024-01-08 13:13:58 +01:00
|
|
|
ynh_setup_source --dest_dir=$install_dir/games/minetest_game --source_id=minetest_game
|
2021-05-18 03:14:18 +02:00
|
|
|
fi
|
2019-10-22 17:52:18 +02:00
|
|
|
|
2024-01-05 14:52:33 +01:00
|
|
|
# Install IrrlichtMt
|
2024-01-08 13:13:58 +01:00
|
|
|
ynh_setup_source --dest_dir=$install_dir/lib/irrlichtmt --source_id=irrlichtmt
|
2024-01-05 14:52:33 +01:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
pushd $install_dir
|
2021-05-19 21:12:05 +02:00
|
|
|
ynh_exec_warn_less cmake . -DRUN_IN_PLACE=TRUE -DENABLE_LUAJIT=TRUE -DBUILD_CLIENT=FALSE -DBUILD_SERVER=TRUE
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2021-05-19 21:12:05 +02:00
|
|
|
ynh_exec_warn_less make -j$(nproc)
|
2019-10-23 12:06:42 +02:00
|
|
|
popd
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-19 04:22:13 +02:00
|
|
|
# ADD A CONFIGURATION
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
#REMOVEME? if [ $is_public -eq 1 ]; then
|
2021-04-18 07:45:09 +02:00
|
|
|
announce="true"
|
2021-04-17 19:56:32 +02:00
|
|
|
else
|
2021-05-16 18:15:51 +02:00
|
|
|
announce="false"
|
2021-04-17 19:56:32 +02:00
|
|
|
fi
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
ynh_add_config --template="../conf/minetest.conf" --destination="$data_dir/.minetest/minetest.conf"
|
2022-06-19 04:22:13 +02:00
|
|
|
|
2024-01-08 13:13:58 +01:00
|
|
|
chmod 400 "$data_dir/.minetest/minetest.conf"
|
|
|
|
chown $app:$app "$data_dir/.minetest/minetest.conf"
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
2022-06-19 04:22:13 +02:00
|
|
|
# SETUP SYSTEMD
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
2022-06-19 04:22:13 +02:00
|
|
|
ynh_script_progression --message="Configuring a systemd service..."
|
2019-08-15 14:21:00 +02:00
|
|
|
|
2022-06-19 04:22:13 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2017-10-20 10:16:34 +02:00
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
2020-12-03 11:19:43 +01:00
|
|
|
ynh_script_progression --message="Configuring log rotation..."
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2022-06-19 04:22:13 +02:00
|
|
|
mkdir -p /var/log/$app
|
|
|
|
chown -R $app:$app /var/log/$app
|
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2020-12-03 11:33:58 +01:00
|
|
|
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
|
2019-04-21 15:32:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2019-04-21 15:32:30 +02:00
|
|
|
|
2021-05-16 18:15:51 +02:00
|
|
|
# Start a systemd service
|
2019-10-26 22:38:40 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/minetest.log" --line_match="listening on"
|
2019-04-21 15:32:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-05-16 18:15:51 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|