diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8727f14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +~.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index e7cbf70..6acf4b5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,6 +19,7 @@ cpe = "cpe:2.3:a:matrix:element" [integration] yunohost = ">= 11.2" +helpers_version = "2.1" architectures = "all" multi_instance = true diff --git a/scripts/_common.sh b/scripts/_common.sh index c71aa26..cb1662c 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,24 +1,12 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= configure_element() { - ynh_add_config --template="config.json" --destination="$install_dir/config.json" + ynh_config_add --template="config.json" --destination="$install_dir/config.json" chmod -R u=rwX,g=rX,o= "$install_dir" chown -R $app:www-data "$install_dir" } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 52eea5b..af443d9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,34 +1,25 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# 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 /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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 "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index ab2d658..2678882 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,22 +1,16 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/config b/scripts/config index 3c2c734..5652989 100644 --- a/scripts/config +++ b/scripts/config @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ./_common.sh source /usr/share/yunohost/helpers @@ -14,8 +8,6 @@ ynh_app_config_apply() { configure_element } -#================================================= -# GENERIC FINALIZATION #================================================= # SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT #================================================= diff --git a/scripts/install b/scripts/install index 940db4a..51d43c9 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -22,19 +16,19 @@ default_federate=true default_theme=light show_labs_settings=false -ynh_app_setting_set --app=$app --key=disable_custom_urls --value=$disable_custom_urls -ynh_app_setting_set --app=$app --key=disable_guests --value=$disable_guests -ynh_app_setting_set --app=$app --key=disable_3pid_login --value=$disable_3pid_login -ynh_app_setting_set --app=$app --key=default_country_code --value=$default_country_code -ynh_app_setting_set --app=$app --key=brand_text --value=$brand_text -ynh_app_setting_set --app=$app --key=default_federate --value=$default_federate -ynh_app_setting_set --app=$app --key=default_theme --value=$default_theme -ynh_app_setting_set --app=$app --key=show_labs_settings --value=$show_labs_settings +ynh_app_setting_set --key=disable_custom_urls --value=$disable_custom_urls +ynh_app_setting_set --key=disable_guests --value=$disable_guests +ynh_app_setting_set --key=disable_3pid_login --value=$disable_3pid_login +ynh_app_setting_set --key=default_country_code --value=$default_country_code +ynh_app_setting_set --key=brand_text --value=$brand_text +ynh_app_setting_set --key=default_federate --value=$default_federate +ynh_app_setting_set --key=default_theme --value=$default_theme +ynh_app_setting_set --key=show_labs_settings --value=$show_labs_settings #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=4 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -42,15 +36,15 @@ ynh_setup_source --dest_dir="$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." configure_element @@ -58,4 +52,4 @@ configure_element # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index b41853e..3a218e8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,24 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 470dc24..0289e6e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# 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 /usr/share/yunohost/helpers @@ -13,23 +7,23 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index bf9e67d..b746d4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,71 +1,65 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message='Ensuring downward compatibility...' --weight=1 +ynh_script_progression 'Ensuring downward compatibility...' if [ -z "${default_home_server:-}" ]; then default_home_server='matrix.org' - ynh_app_setting_set --app=$app --key=default_home_server --value=$default_home_server + ynh_app_setting_set --key=default_home_server --value=$default_home_server fi if [ -z "${disable_custom_urls:-}" ]; then disable_custom_urls=false - ynh_app_setting_set --app=$app --key=disable_custom_urls --value=$disable_custom_urls + ynh_app_setting_set --key=disable_custom_urls --value=$disable_custom_urls fi if [ -z "${disable_guests:-}" ]; then disable_guests=false - ynh_app_setting_set --app=$app --key=disable_guests --value=$disable_guests + ynh_app_setting_set --key=disable_guests --value=$disable_guests fi if [ -z "${disable_3pid_login:-}" ]; then disable_3pid_login=false - ynh_app_setting_set --app=$app --key=disable_3pid_login --value=$disable_3pid_login + ynh_app_setting_set --key=disable_3pid_login --value=$disable_3pid_login fi if [ -z "${default_country_code:-}" ]; then default_country_code=false - ynh_app_setting_set --app=$app --key=default_country_code --value=$default_country_code + ynh_app_setting_set --key=default_country_code --value=$default_country_code fi if [ -z "${brand_text:-}" ]; then brand_text=Element - ynh_app_setting_set --app=$app --key=brand_text --value=$brand_text + ynh_app_setting_set --key=brand_text --value=$brand_text fi if [ -z "${default_federate:-}" ]; then default_federate=true - ynh_app_setting_set --app=$app --key=default_federate --value=$default_federate + ynh_app_setting_set --key=default_federate --value=$default_federate fi if [ -z "${default_theme:-}" ]; then default_theme=light - ynh_app_setting_set --app=$app --key=default_theme --value=$default_theme + ynh_app_setting_set --key=default_theme --value=$default_theme fi if [ -z "${show_labs_settings:-}" ]; then show_labs_settings=false - ynh_app_setting_set --app=$app --key=show_labs_settings --value=$show_labs_settings + ynh_app_setting_set --key=show_labs_settings --value=$show_labs_settings fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config.json" +ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="config.json" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -73,20 +67,20 @@ chown -R $app:www-data "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." configure_element #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"