1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minetest_ynh.git synced 2024-09-03 20:36:00 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2021-05-16 18:15:51 +02:00
parent 3b0aae8b96
commit ed03f31812
7 changed files with 189 additions and 172 deletions

View file

@ -1,19 +1,14 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet minetest_game ;; Test complet minetest_game
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
pvp=1 pvp=1
servername="packagecheck" servername="packagecheck"
game="minetest_game" game="minetest_game"
creative=0 creative=0
damage=1 damage=1
is_public=0 (PUBLIC|public=1|private=0) is_public=0
password="pass" password="pass"
port="30000" (PORT) port="30000"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0

View file

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
@ -8,6 +7,10 @@
# dependencies used by the app # dependencies used by the app
pkg_dependencies="build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libluajit-5.1-dev" pkg_dependencies="build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libluajit-5.1-dev"
#=================================================
# PERSONAL HELPERS
#=================================================
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -15,9 +15,8 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting # Need for the param line_match of ynh_systemd_action ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -42,12 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE HOME DIR
#=================================================
ynh_backup --src_path="$home_path"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -62,7 +55,14 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE HOME DIR
#=================================================
ynh_backup --src_path="$home_path" --is_big
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -14,9 +14,8 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting # Need for the param line_match of ynh_systemd_action ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -25,6 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
game=$YNH_APP_ARG_GAME game=$YNH_APP_ARG_GAME
pvp=$YNH_APP_ARG_PVP pvp=$YNH_APP_ARG_PVP
@ -33,7 +33,6 @@ damage=$YNH_APP_ARG_DAMAGE
servername=$YNH_APP_ARG_SERVERNAME servername=$YNH_APP_ARG_SERVERNAME
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
path_url="/"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -41,7 +40,10 @@ path_url="/"
ynh_script_progression --message="Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..."
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
@ -51,7 +53,6 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=game --value=$game ynh_app_setting_set --app=$app --key=game --value=$game
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=pvp --value=$pvp 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=creative --value=$creative
ynh_app_setting_set --app=$app --key=damage --value=$damage ynh_app_setting_set --app=$app --key=damage --value=$damage
@ -64,11 +65,12 @@ ynh_app_setting_set --app=$app --key=servername --value=$servername
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." ynh_script_progression --message="Finding an available port..."
# Find a free port # Find an available port
port=$(ynh_find_port 30000) port=$(ynh_find_port 30000)
# Open this port
ynh_exec_warn_less yunohost firewall allow --no-upnp UDP $port
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
# Open the port
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow --no-upnp UDP $port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
@ -77,15 +79,6 @@ ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -97,9 +90,30 @@ ynh_app_setting_set --app=$app --key=home_path --value=$home_path
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir=$home_path --use_shell ynh_system_user_create --username=$app --home_dir=$home_path --use_shell
mkdir -p "$home_path"
chmod 750 "$home_path"
chmod -R o-rwx "$home_path"
chown -R $app:$app "$home_path"
#================================================= #=================================================
# COPY CONFIG FILE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
mkdir -p $home_path/.minetest/worlds/ mkdir -p $home_path/.minetest/worlds/
cp -a ../conf/minetest.conf $home_path/.minetest/ cp -a ../conf/minetest.conf $home_path/.minetest/
@ -113,8 +127,10 @@ ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# SPECIFIC SETUP # BUILDING
#================================================= #=================================================
ynh_script_progression --message="Building Minetest..."
# Compile Minetest # Compile Minetest
pushd /opt/yunohost/$app pushd /opt/yunohost/$app
@ -135,6 +151,7 @@ popd
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
### `ynh_replace_string` is used to replace a string in a file. ### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax) ### (It's compatible with sed regular expressions syntax)
@ -143,37 +160,23 @@ popd
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]; then
announce="true" announce="true"
else else
announce="fase" announce="false"
fi fi
ynh_add_config --template="../conf/minetest.conf" --destination="$home_path/.minetest/minetest.conf" ynh_add_config --template="../conf/minetest.conf" --destination="$home_path/.minetest/minetest.conf"
#================================================= #=================================================
# CREATE WORLD # CREATE LOG DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating log directory..."
mkdir -p /var/log/$app mkdir -p /var/log/$app
# Set permissions on logs # Set permissions on logs
chown -R $app:$app /var/log/$app chown -R $app:$app /var/log/$app
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$home_path/.minetest/minetest.conf"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R $app: $home_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -183,20 +186,22 @@ ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate ynh_use_logrotate
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
#================================================= #=================================================
# RELOAD MINETEST # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Reloading Minetest..." 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" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/minetest.log" --line_match="listening on"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Installation of $app completed" ynh_script_progression --message="Installation of $app completed"

View file

@ -23,20 +23,20 @@ home_path=$(ynh_app_setting_get --app=$app --key=home_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove a service from the admin panel, added by `yunohost service add` # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if yunohost service status $app >/dev/null 2>&1 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service" ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service" ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -44,7 +44,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies" ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -52,19 +52,15 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory" ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="$home_path"
# Remove the log files
ynh_secure_remove "/var/log/$app"
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration" ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -79,12 +75,24 @@ then
ynh_exec_warn_less yunohost firewall disallow UDP $port ynh_exec_warn_less yunohost firewall disallow UDP $port
fi fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="$home_path"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user" ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app

View file

@ -15,16 +15,15 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting # Need for the param line_match of ynh_systemd_action ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,13 +34,6 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -50,16 +42,16 @@ ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$home_path --use_shell ynh_system_user_create --username=$app --home_dir=$home_path --use_shell
# Restore home_path
ynh_restore_file --origin_path="$home_path"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..."
# Restore permissions on app files ynh_restore_file --origin_path="$final_path"
chown -R root: $final_path
chown -R $app: $home_path chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -71,6 +63,22 @@ ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
# Restore home_path
ynh_restore_file --origin_path="$home_path" --not_mandatory
mkdir -p "$home_path"
chmod 750 "$home_path"
chmod -R o-rwx "$home_path"
chown -R $app:$app "$home_path"
mkdir /var/log/$app -p
chown -R $app: /var/log/$app
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -79,13 +87,6 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
mkdir /var/log/$app -p
chown -R $app: /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -93,21 +94,22 @@ ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" 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/minetest.log" --line_match="listening on"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# RELOAD MINETEST
#=================================================
ynh_script_progression --message="Reloading minetest..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="listening on"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -25,14 +25,39 @@ pvp=$(ynh_app_setting_get --app=$app --key=pvp)
creative=$(ynh_app_setting_get --app=$app --key=creative) creative=$(ynh_app_setting_get --app=$app --key=creative)
damage=$(ynh_app_setting_get --app=$app --key=damage) damage=$(ynh_app_setting_get --app=$app --key=damage)
servername=$(ynh_app_setting_get --app=$app --key=servername) servername=$(ynh_app_setting_get --app=$app --key=servername)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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 # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -66,23 +91,13 @@ if ynh_legacy_permissions_exists; then
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Making sure dedicated system user exists..."
# Backup the current version of the app # Create a dedicated user (if not existing)
ynh_backup_before_upgrade ynh_system_user_create --username=$app --home_dir=$home_path --use_shell
ynh_clean_setup () {
ynh_clean_check_starting # Need for the param line_match of ynh_systemd_action
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -99,6 +114,10 @@ then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -106,22 +125,6 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$home_path --use_shell
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# COPY CONFIG FILE # COPY CONFIG FILE
#================================================= #=================================================
@ -159,9 +162,9 @@ make -j$(nproc)
popd popd
#================================================= #=================================================
# MODIFY A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..."
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]; then
announce="true" announce="true"
else else
@ -170,6 +173,16 @@ fi
ynh_add_config --template="../conf/minetest.conf" --destination="$home_path/.minetest/minetest.conf" ynh_add_config --template="../conf/minetest.conf" --destination="$home_path/.minetest/minetest.conf"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -179,27 +192,18 @@ ynh_script_progression --message="Upgrading logrotate configuration..."
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#================================================= #=================================================
# GENERIC FINALIZATION # INTEGRATE SERVICE IN YUNOHOST
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
chown -R $app: $home_path
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
#================================================= #=================================================
# RELOAD MINETEST # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Restarting Minetest..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$app/$app.log" --line_match="listening on" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="listening on"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT