1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minetest_ynh.git synced 2024-09-03 20:36:00 +02:00
minetest_ynh/scripts/install
Éric Gaspar 74ab0698df fix
2024-01-08 13:29:31 +01:00

91 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building Minetest..."
# Install the game
if [ $game = "capturetheflag" ]; then
pushd $install_dir
git clone --recursive https://github.com/MT-CTF/capturetheflag.git games/capturetheflag
popd
else
# Download Minetest Game
ynh_setup_source --dest_dir=$install_dir/games/minetest_game --source_id=minetest_game
fi
# Install IrrlichtMt
ynh_setup_source --dest_dir=$install_dir/lib/irrlichtmt --source_id=irrlichtmt
pushd $install_dir
ynh_exec_warn_less cmake . -DRUN_IN_PLACE=TRUE -DENABLE_LUAJIT=TRUE -DBUILD_CLIENT=FALSE -DBUILD_SERVER=TRUE
ynh_exec_warn_less make -j$(nproc)
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
if [ $is_public -eq 1 ]; then
announce="true"
else
announce="false"
fi
ynh_add_config --template="minetest.conf" --destination="$data_dir/.minetest/minetest.conf"
chmod 400 "$data_dir/.minetest/minetest.conf"
chown $app:$app "$data_dir/.minetest/minetest.conf"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
mkdir -p /var/log/$app
chown -R $app:$app /var/log/$app
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/minetest.log" --line_match="listening on"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"