#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." # If game doesn't exist, create it if [ -z $game ]; then game="minetest_game" ynh_app_setting_set --app=$app --key=game --value=$game fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace=1 fi chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" #================================================= # SPECIFIC UPGRADE #================================================= # BUILDING #================================================= ynh_script_progression --message="Building Minetest..." # Install the game if [ $game = "capturetheflag" ]; then # Download Capture The Flag pushd $install_dir # To avoid mess remove this first ynh_secure_remove games/capturetheflag/ # Then clone the latest version from git 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 #================================================= # COPY CONFIG FILE #================================================= if [ -e $data_dir ] then echo "Nothing to do..." else mkdir -p $data_dir/.minetest/ mkdir $data_dir/.minetest/worlds/ fi #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." 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="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append 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..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="listening on" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed"