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/upgrade

131 lines
4 KiB
Text
Raw Normal View History

2017-10-20 11:48:26 +02:00
#!/bin/bash
#=================================================
2019-08-15 14:21:00 +02:00
# GENERIC START
2017-10-20 11:48:26 +02:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
2021-04-18 12:07:00 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
2021-05-16 18:15:51 +02:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
2019-08-15 14:21:00 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2020-12-03 11:33:58 +01:00
ynh_script_progression --message="Ensuring downward compatibility..."
2019-08-15 14:21:00 +02:00
2022-07-19 23:22:01 +02:00
# 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
2017-10-20 11:48:26 +02:00
#=================================================
2019-08-15 14:21:00 +02:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2021-04-17 19:50:44 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2021-04-17 19:56:32 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2021-04-17 19:50:44 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2024-01-08 13:40:09 +01:00
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
2021-04-17 19:50:44 +02:00
fi
2024-01-08 13:13:58 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2021-05-16 18:15:51 +02:00
2019-08-15 14:21:00 +02:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-06-19 04:22:13 +02:00
# BUILDING
#=================================================
ynh_script_progression --message="Building Minetest..."
2021-05-16 18:15:51 +02:00
# Install the game
if [ $game = "capturetheflag" ]; then
# Download Capture The Flag
2024-01-08 13:13:58 +01:00
pushd $install_dir
2021-05-16 18:15:51 +02:00
# 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
2024-01-08 13:13:58 +01:00
ynh_setup_source --dest_dir=$install_dir/games/minetest_game --source_id=minetest_game
fi
2019-10-22 17:52:18 +02: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-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-08-15 14:21:00 +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
2022-06-19 04:22:13 +02:00
#=================================================
# COPY CONFIG FILE
#=================================================
2024-01-08 13:13:58 +01:00
if [ -e $data_dir ]
2022-06-19 04:22:13 +02:00
then
echo "Nothing to do..."
else
2024-01-08 13:13:58 +01:00
mkdir -p $data_dir/.minetest/
mkdir $data_dir/.minetest/worlds/
2022-06-19 04:22:13 +02:00
fi
2019-10-23 12:06:42 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
# UPDATE A CONFIG FILE
2019-10-23 12:06:42 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
ynh_script_progression --message="Updating a configuration file..."
2024-01-08 13:29:31 +01:00
ynh_add_config --template="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-10-23 14:58:46 +02:00
2019-08-15 14:21:00 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
# SETUP SYSTEMD
2019-08-15 14:21:00 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
ynh_script_progression --message="Upgrading systemd configuration..."
2019-08-15 14:21:00 +02:00
2021-05-16 18:15:51 +02:00
# Create a dedicated systemd config
ynh_add_systemd_config
2019-08-15 14:21:00 +02:00
2021-05-16 18:15:51 +02:00
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
2019-08-15 14:21:00 +02:00
2020-12-03 11:28:43 +01:00
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
2020-12-03 11:19:43 +01:00
2019-08-15 14:21:00 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
# START SYSTEMD SERVICE
2019-08-15 14:21:00 +02:00
#=================================================
2021-05-16 18:15:51 +02:00
ynh_script_progression --message="Starting a systemd service..."
2019-08-15 14:21:00 +02:00
2021-05-16 18:15:51 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="listening on"
2019-08-15 14:21:00 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2020-12-03 11:33:58 +01:00
ynh_script_progression --message="Upgrade of $app completed"