1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mumbleserver_ynh.git synced 2024-09-03 19:46:03 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-06-20 03:33:15 +02:00
parent dfc65ba517
commit f12ea533cd
7 changed files with 117 additions and 104 deletions

View file

@ -12,12 +12,14 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
# 1.3.0~ynh1
upgrade=1 from_commit=d9ece341d532bd5eac9af9ce191da7b62d1e8bb1 upgrade=1 from_commit=d9ece341d532bd5eac9af9ce191da7b62d1e8bb1
# 1.3.0~ynh2
upgrade=1 from_commit=fc6ca3fa6abe234314089fd58ef884759ebe4fd9
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0
change_url=0
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=d9ece341d532bd5eac9af9ce191da7b62d1e8bb1
name=Merge pull request #40 from YunoHost-Apps/testing

View file

@ -6,7 +6,7 @@
"en": "Low-latency, high quality voice chat software (VoIP)", "en": "Low-latency, high quality voice chat software (VoIP)",
"fr": "Logiciel libre de voix sur IP (VoIP)" "fr": "Logiciel libre de voix sur IP (VoIP)"
}, },
"version": "1.3.0~ynh2", "version": "1.3.0~ynh3",
"url": "https://mumble.info", "url": "https://mumble.info",
"upstream": { "upstream": {
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
@ -30,30 +30,30 @@
"services": [ "services": [
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{
"name": "domain",
"type": "domain"
},
{ {
"name": "welcometext", "name": "domain",
"type": "string", "type": "domain"
"ask": {
"en": "Choose a welcome text for your server",
"fr": "Choisissez un message de bienvenue pour le serveur"
},
"example": "Welcome to my Mumble server",
"default": "Welcome"
}, },
{ {
"name": "registername", "name": "welcometext",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose a name for the root channel (your Mumble server name)", "en": "Choose a welcome text for your server",
"fr": "Entrez un nom pour le channel racine (le nom de votre serveur Mumble)" "fr": "Choisissez un message de bienvenue pour le serveur"
},
"example": "Welcome to my Mumble server",
"default": "Welcome"
}, },
"example": "Root", {
"default": "Root" "name": "registername",
"type": "string",
"ask": {
"en": "Choose a name for the root channel (your Mumble server name)",
"fr": "Entrez un nom pour le channel racine (le nom de votre serveur Mumble)"
},
"example": "Root",
"default": "Root"
} }
] ]
} }

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,6 +14,7 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
@ -29,8 +31,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================

View file

@ -15,6 +15,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
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
@ -22,13 +25,13 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
app=$YNH_APP_INSTANCE_NAME
welcometext=$YNH_APP_ARG_WELCOMETEXT welcometext=$YNH_APP_ARG_WELCOMETEXT
registername=$YNH_APP_ARG_REGISTERNAME registername=$YNH_APP_ARG_REGISTERNAME
instance_id=$YNH_APP_INSTANCE_NUMBER instance_id=$YNH_APP_INSTANCE_NUMBER
app=$YNH_APP_INSTANCE_NAME
server_password=$(ynh_string_random) server_password=$(ynh_string_random)
su_passwd=$(ynh_string_random) su_passwd=$(ynh_string_random)
@ -38,7 +41,7 @@ su_passwd=$(ynh_string_random)
ynh_script_progression --message="Validating installation parameters..." --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app final_path=/var/www/$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"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
@ -46,13 +49,13 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_script_progression --message="Storing installation settings..." --weight=2
# Save app settings # Save app 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=no_sso --value="true" ynh_app_setting_set --app=$app --key=no_sso --value="true"
ynh_app_setting_set --app=$app --key=server_password --value="$server_password" ynh_app_setting_set --app=$app --key=server_password --value="$server_password"
ynh_app_setting_set --app=$app --key=su_passwd --value="$su_passwd" ynh_app_setting_set --app=$app --key=su_passwd --value="$su_passwd"
ynh_app_setting_set --app=$app --key=welcometext --value="$welcometext" ynh_app_setting_set --app=$app --key=welcometext --value="$welcometext"
ynh_app_setting_set --app=$app --key=registername --value="$registername" ynh_app_setting_set --app=$app --key=registername --value="$registername"
ynh_app_setting_set --app=$app --key=instance_id --value="$instance_id" ynh_app_setting_set --app=$app --key=instance_id --value="$instance_id"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -61,6 +64,7 @@ ynh_app_setting_set --app=$app --key=instance_id --value="$instance_id"
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=1 ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=64738) port=$(ynh_find_port --port=64738)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
@ -73,14 +77,14 @@ ynh_exec_warn_less yunohost firewall allow Both $port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=4 ynh_script_progression --message="Installing dependencies..." --weight=4
# Install Mumble Debian package via apt
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# mumble server conf.ini # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
mkdir -p "$final_path" mkdir -p "$final_path"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
@ -90,19 +94,6 @@ mumble_conf="$final_path/mumble-server.ini"
ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf" ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf"
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chmod -R 770 "$final_path" chmod -R 770 "$final_path"
chown -R :mumble-server "$final_path" chown -R :mumble-server "$final_path"
@ -128,12 +119,21 @@ ynh_exec_warn_less murmurd -ini "$mumble_conf" -supw "$su_passwd" "$instance_id"
systemctl stop mumble-server systemctl stop mumble-server
systemctl disable mumble-server --quiet systemctl disable mumble-server --quiet
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
# Add Mumble as a YunoHost service
yunohost service add $app --description="Mumble server" --log="/var/log/mumble-server/$app.log" --needs_exposed_ports="$port" yunohost service add $app --description="Mumble server" --log="/var/log/mumble-server/$app.log" --needs_exposed_ports="$port"
#================================================= #=================================================

View file

@ -23,7 +23,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
@ -41,14 +41,6 @@ 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
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -57,21 +49,30 @@ ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_script_progression --message="Close port $port" --weight=1 ynh_script_progression --message="Closing port $port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow Both $port ynh_exec_warn_less yunohost firewall disallow Both $port
fi fi
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE OTHER FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/var/log/mumble-server/$app.log" ynh_secure_remove --file="/var/log/mumble-server/$app.log"

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,6 +14,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
@ -30,7 +35,8 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d "$final_path" || ynh_die "There is already a directory: $final_path " test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -72,14 +78,6 @@ usermod --append --groups ssl-cert mumble-server
systemctl stop mumble-server systemctl stop mumble-server
systemctl disable mumble-server --quiet systemctl disable mumble-server --quiet
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Add Mumble as a YunoHost service
yunohost service add $app --description="Mumble server" --log="/var/log/mumble-server/$app.log" --needs_exposed_ports="$port"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -88,6 +86,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
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
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Mumble server" --log="/var/log/mumble-server/$app.log" --needs_exposed_ports="$port"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -29,9 +29,34 @@ instance_id=$(ynh_app_setting_get --app=$app --key=instance_id)
#================================================= #=================================================
# 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)..." --weight=5
# 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
#================================================= #=================================================
@ -106,32 +131,16 @@ if [ -z "$registername" ]; then
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6 ynh_script_progression --message="Upgrading dependencies..." --weight=6
# Install Mumble Debian package via apt
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# mumble server conf.ini # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
@ -142,20 +151,6 @@ mumble_conf="$final_path/mumble-server.ini"
ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf" ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chmod -R 770 "$final_path" chmod -R 770 "$final_path"
chown -R :mumble-server "$final_path" chown -R :mumble-server "$final_path"
@ -181,7 +176,17 @@ systemctl stop mumble-server
systemctl disable mumble-server --quiet systemctl disable mumble-server --quiet
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1