From 3082db38011b7e23716ced12ce8992e318e42cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 31 Oct 2023 22:19:40 +0100 Subject: [PATCH] Migrate with script --- conf/armv7_bookworm.src | 7 -- conf/armv7_bullseye.src | 7 -- manifest.toml | 78 +++++++++++++++++ scripts/_common.sh | 40 ++++----- scripts/backup | 16 ++-- scripts/change_url | 68 +++++++------- scripts/install | 96 ++++++++++---------- scripts/remove | 32 +++---- scripts/restore | 58 ++++++------ scripts/upgrade | 190 ++++++++++++++++++++-------------------- 10 files changed, 329 insertions(+), 263 deletions(-) delete mode 100644 conf/armv7_bookworm.src delete mode 100644 conf/armv7_bullseye.src create mode 100644 manifest.toml diff --git a/conf/armv7_bookworm.src b/conf/armv7_bookworm.src deleted file mode 100644 index 5430fcd..0000000 --- a/conf/armv7_bookworm.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.95.0/matrix-synapse_1.95.0-bookworm-bin1_armv7l.tar.gz -SOURCE_SUM=1a1d9248b139f67d23a89a20745d14d88c5b8627f76872d7f94f66952b5f1253 -# (Optional) Program to check the integrity (sha256sum, md5sum...) -# default: sha256 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true diff --git a/conf/armv7_bullseye.src b/conf/armv7_bullseye.src deleted file mode 100644 index 2b18ef8..0000000 --- a/conf/armv7_bullseye.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.95.0/matrix-synapse_1.95.0-bullseye-bin1_armv7l.tar.gz -SOURCE_SUM=97e9942bea9bcecc2a75228255a1824298300302559a9332e50816fa54193738 -# (Optional) Program to check the integrity (sha256sum, md5sum...) -# default: sha256 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..12ec0d3 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,78 @@ +packaging_format = 2 + +id = "synapse" +name = "Synapse" +description.en = "Instant messaging server which uses Matrix" +description.fr = "Serveur de messagerie instantané basé sur Matrix" + +version = "1.95.0~ynh1" + +maintainers = ["Josué Tille"] + +[upstream] +license = "Apache-2.0" +website = "https://matrix.org/" +code = "https://github.com/matrix-org/synapse" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.2" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.server_name] + ask.en = "If your Synapse domain is a subdomain, you can choose a name for your Synapse server to have your Matrix user-ids looking like @user:domain.org instead of @user:synapse.domain.org" + ask.fr = "Si votre domaine pour Synapse est un sous-domaine, vous pouvez choisir un nom pour votre serveur Synapse afin que vos identifiants Matrix soient @utilisateur:domain.org plutôt que @utilisateur:synapse.domain.org" + type = "string" + example = "domain.org" + default = "Same than the domain" + + [install.is_free_registration] + ask.en = "Is it a server with free registration?" + ask.fr = "Est-ce un serveur avec création de compte libre ?" + help.en = "A public server means that anybody will be able to register on this server." + help.fr = "Un serveur public signifie que n'importe qui pourra s'enregistrer sur ce serveur." + type = "boolean" + default = false + + [install.jitsi_server] + ask.en = "Jitsi server address for conferencing?" + ask.fr = "Adresse du serveur Jitsi pour les conférences ?" + type = "string" + example = "domain.org" + default = "jitsi.riot.im" + +[resources] + [resources.sources] + [resources.sources.armv7_bookworm] + url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.95.0/matrix-synapse_1.95.0-bookworm-bin1_armv7l.tar.gz" + sha256 = "1a1d9248b139f67d23a89a20745d14d88c5b8627f76872d7f94f66952b5f1253" + + [resources.sources.armv7_bullseye] + url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.95.0/matrix-synapse_1.95.0-bullseye-bin1_armv7l.tar.gz" + sha256 = "97e9942bea9bcecc2a75228255a1824298300302559a9332e50816fa54193738" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + + [resources.ports] + synapse_tls.default = 8448 + main.default = 8008 + turnserver_tls.default = 5349 + turnserver_alt_tls.default = 12345 + cli.default = 5766 diff --git a/scripts/_common.sh b/scripts/_common.sh index b78a3b2..44a5391 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,57 +1,57 @@ dependances="coturn build-essential python3-dev libffi-dev python3-pip python3-setuptools sqlite3 libssl-dev python3-venv libxml2-dev libxslt1-dev python3-lxml zlib1g-dev libjpeg-dev libpq-dev postgresql acl" python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME install_sources() { # Install/upgrade synapse in virtualenv # Clean venv is it was on python2.7 or python3 with old version in case major upgrade of debian - if [ ! -e $final_path/bin/python3 ] || [ ! -e $final_path/lib/python$python_version ]; then - ynh_secure_remove --file=$final_path/bin - ynh_secure_remove --file=$final_path/lib - ynh_secure_remove --file=$final_path/lib64 - ynh_secure_remove --file=$final_path/include - ynh_secure_remove --file=$final_path/share - ynh_secure_remove --file=$final_path/pyvenv.cfg + if [ ! -e $install_dir/bin/python3 ] || [ ! -e $install_dir/lib/python$python_version ]; then +#REMOVEME? ynh_secure_remove --file=$install_dir/bin +#REMOVEME? ynh_secure_remove --file=$install_dir/lib +#REMOVEME? ynh_secure_remove --file=$install_dir/lib64 +#REMOVEME? ynh_secure_remove --file=$install_dir/include +#REMOVEME? ynh_secure_remove --file=$install_dir/share +#REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg fi - mkdir -p $final_path - chown $synapse_user:root -R $final_path + mkdir -p $install_dir + chown $synapse_user:root -R $install_dir if [ -n "$(uname -m | grep arm)" ] then # Clean old file, sometimes it could make some big issues if we don't do this!! - ynh_secure_remove --file=$final_path/bin - ynh_secure_remove --file=$final_path/lib - ynh_secure_remove --file=$final_path/include - ynh_secure_remove --file=$final_path/share +#REMOVEME? ynh_secure_remove --file=$install_dir/bin +#REMOVEME? ynh_secure_remove --file=$install_dir/lib +#REMOVEME? ynh_secure_remove --file=$install_dir/include +#REMOVEME? ynh_secure_remove --file=$install_dir/share - ynh_setup_source --dest_dir=$final_path/ --source_id="armv7_$(lsb_release --codename --short)" + ynh_setup_source --dest_dir=$install_dir/ --source_id="armv7_$(lsb_release --codename --short)" # Fix multi-instance support - for f in $(ls $final_path/bin); do + for f in $(ls $install_dir/bin); do if ! [[ $f =~ "__" ]]; then - ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$final_path --target_file=$final_path/bin/$f + ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$install_dir --target_file=$install_dir/bin/$f fi done else # Install virtualenv if it don't exist - test -e $final_path/bin/python3 || python3 -m venv $final_path +#REMOVEME? test -e $install_dir/bin/python3 || python3 -m venv $install_dir # Install synapse in virtualenv # We set all necessary environement variable to create a python virtualenvironnement. u_arg='u' set +$u_arg; - source $final_path/bin/activate + source $install_dir/bin/activate set -$u_arg; pip3 install --upgrade setuptools wheel pip pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2 pip3 install --upgrade -r $YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt - # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does + # This function was defined when we called "source $install_dir/bin/activate". With this function we undo what "$install_dir/bin/activate" does set +$u_arg; deactivate set -$u_arg; diff --git a/scripts/backup b/scripts/backup index 775dbab..c3588b0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,19 +15,19 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) if [[ ! "$(systemctl status matrix-$app.service)" =~ "Active: inactive (dead)" ]]; then ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop matrix-$app.service'" @@ -56,7 +56,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" ynh_backup --src_path="$final_www_path" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 7439d93..75398f0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,39 +8,39 @@ source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors # Import common cmd source ./experimental_helper.sh source ./_common.sh -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." # RETRIEVE ARGUMENTS -old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN domain=$YNH_APP_NEW_DOMAIN -path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH) -app=$YNH_APP_INSTANCE_NAME +path=$(ynh_normalize_url_path --path $YNH_APP_NEW_PATH) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_old_version=$(ynh_app_setting_get --app=$app --key=synapse_version) -jitsi_server=$(ynh_app_setting_get --app=$app --key=jitsi_server) -is_free_registration=$(ynh_app_setting_get --app=$app --key=is_free_registration) -port=$(ynh_app_setting_get --app=$app --key=synapse_port) -synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) -turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) -cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) -report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) -allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) -e2e_enabled_by_default=$(ynh_app_setting_get --app=$app --key=e2e_enabled_by_default) -synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) -turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) -registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) -form_secret=$(ynh_app_setting_get --app=$app --key=form_secret) -macaroon_secret_key=$(ynh_app_setting_get --app=$app --key=macaroon_secret_key) -synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) +#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? synapse_old_version=$(ynh_app_setting_get --app=$app --key=synapse_version) +#REMOVEME? jitsi_server=$(ynh_app_setting_get --app=$app --key=jitsi_server) +#REMOVEME? is_free_registration=$(ynh_app_setting_get --app=$app --key=is_free_registration) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=synapse_port) +#REMOVEME? synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) +#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) +#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) +#REMOVEME? cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) +#REMOVEME? report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) +#REMOVEME? allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) +#REMOVEME? e2e_enabled_by_default=$(ynh_app_setting_get --app=$app --key=e2e_enabled_by_default) +#REMOVEME? synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) +#REMOVEME? turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) +#REMOVEME? registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) +#REMOVEME? form_secret=$(ynh_app_setting_get --app=$app --key=form_secret) +#REMOVEME? macaroon_secret_key=$(ynh_app_setting_get --app=$app --key=macaroon_secret_key) +#REMOVEME? synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) main_domain=$(yunohost domain list --output-as json | jq -r .main) synapse_user="matrix-$app" @@ -54,12 +54,12 @@ domain_whitelist_client=${domain_whitelist_client_%"\n"} # Check if the new path stay /_matrix if not exit -if [[ $path_url != "/_matrix" ]] +if [[ $path != "/_matrix" ]] then ynh_die --message "You can't use an other path than '/_matrix'. You can only change the domain." fi -# We stop the service before to set ynh_clean_setup +#REMOVEME? # We stop the service before to set ynh_clean_setup ynh_systemd_action --service_name=matrix-$app.service --action=stop #================================================= @@ -70,20 +70,22 @@ ynh_systemd_action --service_name=matrix-$app.service --action=stop ynh_script_progression --message="Updating NGINX configuration..." -# MODIFY URL IN NGINX CONF -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config -# Change the domain for nginx +# MODIFY URL IN NGINX CONF +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +#REMOVEME? # Change the domain for nginx # Delete file checksum for the old conf file location -ynh_delete_file_checksum --file "$nginx_conf_path" -mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file "$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf # Store file checksum for the new config file location -ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf" # Create .well-known redirection for access by federation if yunohost --output-as plain domain list | grep -q "^$server_name$" then - ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +#REMOVEME? ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" fi #================================================= diff --git a/scripts/install b/scripts/install index 28e8871..a20c284 100644 --- a/scripts/install +++ b/scripts/install @@ -14,12 +14,12 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { # Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # SET CONSTANTS @@ -42,12 +42,12 @@ domain_whitelist_client=${domain_whitelist_client_%"\n"} # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -server_name=$YNH_APP_ARG_SERVER_NAME -is_free_registration=$YNH_APP_ARG_IS_FREE_REGISTRATION -jitsi_server=$YNH_APP_ARG_JITSI_SERVER -path_url="/_matrix" -final_path="/opt/yunohost/matrix-$app" +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? server_name=$YNH_APP_ARG_SERVER_NAME +#REMOVEME? is_free_registration=$YNH_APP_ARG_IS_FREE_REGISTRATION +#REMOVEME? jitsi_server=$YNH_APP_ARG_JITSI_SERVER +path="/_matrix" +#REMOVEME? install_dir="/opt/yunohost/matrix-$app" final_www_path="/var/www/$app" data_path="/home/yunohost.app/matrix-$app" main_domain=$(yunohost domain list --output-as json | jq -r .main) @@ -59,11 +59,11 @@ fi #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=2 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2 test ! -e "/etc/nginx/conf.d/$domain.d/synapse*.conf" || ynh_die --message="$domain is not available as domain, please use an other domain." # Check Final Path availability -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" if [ -e "$data_path" ]; then old_data_dir_path="$data_path$(date '+%Y%m%d.%H%M%S')" @@ -74,15 +74,15 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=jitsi_server --value=$jitsi_server -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir ynh_app_setting_set --app=$app --key=synapse_version --value=$upstream_version -ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats +#REMOVEME? ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_app_pwd @@ -104,7 +104,7 @@ fi ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled -ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled +#REMOVEME? ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup #================================================= @@ -115,8 +115,8 @@ element_ynh_url="https://matrix.to/" # Get app name of first Element Instance (can be changed later in Config Panel) element_instance="element" if yunohost --output-as plain app list | grep -q "^$element_instance$"; then - element_domain=$(ynh_app_setting_get --app $element_instance --key domain) - element_path=$(ynh_app_setting_get --app $element_instance --key path) +#REMOVEME? element_domain=$(ynh_app_setting_get --app $element_instance --key domain) +#REMOVEME? element_path=$(ynh_app_setting_get --app $element_instance --key path) element_ynh_url="https://""$element_domain""$element_path" fi web_client_location=$element_ynh_url @@ -163,7 +163,7 @@ ynh_app_setting_set --app=$app --key=default_identity_server --value=$default_id ynh_app_setting_set --app=$app --key=auto_join_rooms --value=$auto_join_rooms ynh_app_setting_set --app=$app --key=autocreate_auto_join_rooms --value=$autocreate_auto_join_rooms ynh_app_setting_set --app=$app --key=auto_join_rooms_for_guests --value=$auto_join_rooms_for_guests -ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled +#REMOVEME? ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled ynh_app_setting_set --app=$app --key=enable_notifs --value=$enable_notifs ynh_app_setting_set --app=$app --key=notif_for_new_users --value=$notif_for_new_users ynh_app_setting_set --app=$app --key=enable_group_creation --value=$enable_group_creation @@ -178,11 +178,11 @@ ynh_app_setting_set --app=$app --key=push_include_content --value=$push_include_ ynh_script_progression --message="Configuring firewall..." --weight=19 # Find a free port -synapse_tls_port=$(ynh_find_port --port=8448) -port=$(ynh_find_port --port=8008) -turnserver_tls_port=$(ynh_find_port --port=5349) -turnserver_alt_tls_port=$(ynh_find_port --port=$((turnserver_tls_port+1))) -cli_port=$(ynh_find_port --port=5766) +#REMOVEME? synapse_tls_port=$(ynh_find_port --port=8448) +#REMOVEME? port=$(ynh_find_port --port=8008) +#REMOVEME? turnserver_tls_port=$(ynh_find_port --port=5349) +#REMOVEME? turnserver_alt_tls_port=$(ynh_find_port --port=$((turnserver_tls_port+1))) +#REMOVEME? cli_port=$(ynh_find_port --port=5766) # Open this port ynh_exec_warn_less yunohost firewall allow TCP $synapse_tls_port @@ -190,11 +190,11 @@ ynh_exec_warn_less yunohost firewall allow Both $turnserver_tls_port ynh_exec_warn_less yunohost firewall allow Both $turnserver_alt_tls_port # Store opened ports -ynh_app_setting_set --app=$app --key=synapse_port --value=$port -ynh_app_setting_set --app=$app --key=synapse_tls_port --value=$synapse_tls_port -ynh_app_setting_set --app=$app --key=turnserver_tls_port --value=$turnserver_tls_port -ynh_app_setting_set --app=$app --key=turnserver_alt_tls_port --value=$turnserver_alt_tls_port -ynh_app_setting_set --app=$app --key=cli_port --value=$cli_port +#REMOVEME? ynh_app_setting_set --app=$app --key=synapse_port --value=$port +#REMOVEME? ynh_app_setting_set --app=$app --key=synapse_tls_port --value=$synapse_tls_port +#REMOVEME? ynh_app_setting_set --app=$app --key=turnserver_tls_port --value=$turnserver_tls_port +#REMOVEME? ynh_app_setting_set --app=$app --key=turnserver_alt_tls_port --value=$turnserver_alt_tls_port +#REMOVEME? ynh_app_setting_set --app=$app --key=cli_port --value=$cli_port #================================================= # CREATE A DH FILE @@ -215,18 +215,18 @@ fi #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=80 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=80 # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -ynh_exec_warn_less ynh_install_app_dependencies $dependances +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $dependances #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3 -ynh_system_user_create --username=$synapse_user --home_dir=$final_path +#REMOVEME? ynh_system_user_create --username=$synapse_user --home_dir=$install_dir # The format to create an user account varies depending on the version of YunoHost currently installed. ynh_current_version=$(dpkg-query --showformat='${Version}' --show yunohost) if $(dpkg --compare-versions "$ynh_current_version" ge "11.1"); then @@ -240,13 +240,13 @@ adduser turnserver ssl-cert #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=4 +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=4 synapse_db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app=$app --key=synapse_db_pwd --value=$synapse_db_pwd +#REMOVEME? ynh_app_setting_set --app=$app --key=synapse_db_pwd --value=$synapse_db_pwd # Create postgresql database -ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_test_if_first_run ynh_psql_create_user $synapse_db_user $synapse_db_pwd ynh_psql_execute_as_root \ --sql="CREATE DATABASE $synapse_db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $synapse_db_user;" @@ -288,13 +288,13 @@ ynh_script_progression --message="Creating Synapse config..." --weight=3 # Go in virtualenvironnement set +u; -source $final_path/bin/activate +source $install_dir/bin/activate set -u; # Generate config python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --server-name $server_name --report-stats=no -c homeserver.yml -# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does +# This function was defined when we called "source $install_dir/bin/activate". With this function we undo what "$install_dir/bin/activate" does set +u; deactivate set -u; @@ -399,27 +399,27 @@ ynh_use_logrotate --logfile "/var/log/matrix-$app" # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files -ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$final_path/Coturn_config_rotate.sh" -ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$final_path/update_synapse_for_appservice.sh" +ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$install_dir/Coturn_config_rotate.sh" +ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$install_dir/update_synapse_for_appservice.sh" #================================================= # GENERIC FINALIZATION #================================================= # SETUP PERMISSIONS #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_permission_url --permission=main --url=$domain/_matrix/cas_server.php/login --auth_header=true -ynh_permission_update --permission=main --show_tile=false --protected=true +#REMOVEME? ynh_permission_update --permission=main --show_tile=false --protected=true -ynh_permission_create --permission=server_api --url=$domain/_matrix \ +#REMOVEME? ynh_permission_create --permission=server_api --url=$domain/_matrix \ --label="Server access for client apps." --show_tile=false --allowed=visitors \ --auth_header=false --protected=true -ynh_permission_create --permission=admin_api --url=$domain/_synapse \ +#REMOVEME? ynh_permission_create --permission=admin_api --url=$domain/_synapse \ --label="Server administration API." --show_tile=false \ --auth_header=false --allowed=visitors if yunohost --output-as plain domain list | grep -q "^$server_name$"; then - ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ +#REMOVEME? ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ --label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \ --auth_header=false --protected=true fi @@ -439,9 +439,9 @@ ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -chown $synapse_user:root -R $final_path -chmod 770 $final_path/Coturn_config_rotate.sh -chmod 700 $final_path/update_synapse_for_appservice.sh +chown $synapse_user:root -R $install_dir +chmod 770 $install_dir/Coturn_config_rotate.sh +chmod 700 $install_dir/update_synapse_for_appservice.sh chown $synapse_user:root -R $data_path chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app diff --git a/scripts/remove b/scripts/remove index fa86c1a..d158136 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,16 +13,16 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) -turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) +#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) +#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) #================================================= # SET CONSTANTS @@ -64,25 +64,25 @@ ynh_remove_systemd_config --service=coturn-$app #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database" --weight=2 +#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database" --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$synapse_db_name --db_name=$synapse_db_user +#REMOVEME? ynh_psql_remove_db --db_user=$synapse_db_name --db_name=$synapse_db_user #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies" --weight=15 +#REMOVEME? ynh_script_progression --message="Removing dependencies" --weight=15 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory" --weight=2 +#REMOVEME? ynh_script_progression --message="Removing app main directory" --weight=2 -ynh_secure_remove --file=$final_path +#REMOVEME? ynh_secure_remove --file=$install_dir ynh_secure_remove --file=$final_www_path ynh_secure_remove --file=/var/log/matrix-$app ynh_secure_remove --file=/etc/matrix-$app @@ -139,10 +139,10 @@ ynh_remove_fail2ban_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user" --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user" --weight=1 # Delete a system user -ynh_system_user_delete --username=$synapse_user +#REMOVEME? ynh_system_user_delete --username=$synapse_user yunohost user delete $synapse_user_app #================================================= diff --git a/scripts/restore b/scripts/restore index 8c9ddc7..d4a1908 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,30 +15,30 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { # Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) -turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) -synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) +#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) +#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) +#REMOVEME? synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) main_domain=$(yunohost domain list --output-as json | jq -r .main) #================================================= @@ -57,29 +57,29 @@ data_path="/home/yunohost.app/matrix-$app" #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=2 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=70 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=70 # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -ynh_exec_warn_less ynh_install_app_dependencies $dependances +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $dependances #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$synapse_user --home_dir=$final_path +#REMOVEME? ynh_system_user_create --username=$synapse_user --home_dir=$install_dir # The format to create an user account varies depending on the version of YunoHost currently installed. ynh_current_version=$(dpkg-query --showformat='${Version}' --show yunohost) if $(dpkg --compare-versions "$ynh_current_version" ge "11.1"); then @@ -113,9 +113,9 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=13 +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=13 -ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_test_if_first_run ynh_psql_create_user $synapse_db_user $synapse_db_pwd ynh_psql_execute_as_root \ --sql="CREATE DATABASE $synapse_db_name @@ -166,10 +166,10 @@ ynh_script_progression --message="Reconfiguring Coturn..." --weight=23 # To be sure that at the restoration the IP address in coturn config is the same as the real address we remake the coturn config # Retrieve specific settings -turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) -cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) -turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) +#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) +#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) +#REMOVEME? cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) +#REMOVEME? turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) # WARNING : these commands are used in INSTALL, UPGRADE # For any update do it in all files @@ -217,9 +217,9 @@ ynh_use_logrotate --logfile /var/log/matrix-$app # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE (3 times) # For any update do it in all files ynh_script_progression --message="Configuring file permission..." -chown $synapse_user:root -R $final_path -chmod 770 $final_path/Coturn_config_rotate.sh -chmod 700 $final_path/update_synapse_for_appservice.sh +chown $synapse_user:root -R $install_dir +chmod 770 $install_dir/Coturn_config_rotate.sh +chmod 700 $install_dir/update_synapse_for_appservice.sh chown $synapse_user:root -R $data_path chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app diff --git a/scripts/upgrade b/scripts/upgrade index 09810f0..c567090 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,35 +11,35 @@ source experimental_helper.sh source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -jitsi_server=$(ynh_app_setting_get --app=$app --key=jitsi_server) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_old_version=$(ynh_app_setting_get --app=$app --key=synapse_version) -is_free_registration=$(ynh_app_setting_get --app=$app --key=is_free_registration) -port=$(ynh_app_setting_get --app=$app --key=synapse_port) -synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) -turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) -cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) -report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) -e2e_enabled_by_default=$(ynh_app_setting_get --app=$app --key=e2e_enabled_by_default) -synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) -turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) -registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) -form_secret=$(ynh_app_setting_get --app=$app --key=form_secret) -macaroon_secret_key=$(ynh_app_setting_get --app=$app --key=macaroon_secret_key) -synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) +#REMOVEME? jitsi_server=$(ynh_app_setting_get --app=$app --key=jitsi_server) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? synapse_old_version=$(ynh_app_setting_get --app=$app --key=synapse_version) +#REMOVEME? is_free_registration=$(ynh_app_setting_get --app=$app --key=is_free_registration) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=synapse_port) +#REMOVEME? synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) +#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) +#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) +#REMOVEME? cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) +#REMOVEME? report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) +#REMOVEME? e2e_enabled_by_default=$(ynh_app_setting_get --app=$app --key=e2e_enabled_by_default) +#REMOVEME? synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) +#REMOVEME? turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) +#REMOVEME? registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) +#REMOVEME? form_secret=$(ynh_app_setting_get --app=$app --key=form_secret) +#REMOVEME? macaroon_secret_key=$(ynh_app_setting_get --app=$app --key=macaroon_secret_key) +#REMOVEME? synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) domain_whitelist_client_=$(get_domain_list) domain_whitelist_client=${domain_whitelist_client_%"\n"} main_domain=$(yunohost domain list --output-as json | jq -r .main) @@ -62,33 +62,33 @@ data_path="/home/yunohost.app/matrix-$app" # GET CONFIG PANEL SETTINGS #================================================= -server_statistics=$(ynh_app_setting_get --app=$app --key=server_statistics) -web_client_location=$(ynh_app_setting_get --app=$app --key=web_client_location) -client_base_url=$(ynh_app_setting_get --app=$app --key=client_base_url) -invite_client_location=$(ynh_app_setting_get --app=$app --key=invite_client_location) -allow_public_rooms_without_auth=$(ynh_app_setting_get --app=$app --key=allow_public_rooms_without_auth) -allow_public_rooms_over_federation=$(ynh_app_setting_get --app=$app --key=allow_public_rooms_over_federation) -max_upload_size=$(ynh_app_setting_get --app=$app --key=max_upload_size) -disable_msisdn_registration=$(ynh_app_setting_get --app=$app --key=disable_msisdn_registration) -registrations_require_3pid=$(ynh_app_setting_get --app=$app --key=registrations_require_3pid) -allowed_local_3pids_email=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_email) -allowed_local_3pids_msisdn=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_msisdn) -account_threepid_delegates_msisdn=$(ynh_app_setting_get --app=$app --key=account_threepid_delegates_msisdn) -allow_guest_access=$(ynh_app_setting_get --app=$app --key=allow_guest_access) -default_identity_server=$(ynh_app_setting_get --app=$app --key=default_identity_server) -auto_join_rooms=$(ynh_app_setting_get --app=$app --key=auto_join_rooms) -autocreate_auto_join_rooms=$(ynh_app_setting_get --app=$app --key=autocreate_auto_join_rooms) -auto_join_rooms_for_guests=$(ynh_app_setting_get --app=$app --key=auto_join_rooms_for_guests) -enable_notifs=$(ynh_app_setting_get --app=$app --key=enable_notifs) -notif_for_new_users=$(ynh_app_setting_get --app=$app --key=notif_for_new_users) -enable_group_creation=$(ynh_app_setting_get --app=$app --key=enable_group_creation) +#REMOVEME? server_statistics=$(ynh_app_setting_get --app=$app --key=server_statistics) +#REMOVEME? web_client_location=$(ynh_app_setting_get --app=$app --key=web_client_location) +#REMOVEME? client_base_url=$(ynh_app_setting_get --app=$app --key=client_base_url) +#REMOVEME? invite_client_location=$(ynh_app_setting_get --app=$app --key=invite_client_location) +#REMOVEME? allow_public_rooms_without_auth=$(ynh_app_setting_get --app=$app --key=allow_public_rooms_without_auth) +#REMOVEME? allow_public_rooms_over_federation=$(ynh_app_setting_get --app=$app --key=allow_public_rooms_over_federation) +#REMOVEME? max_upload_size=$(ynh_app_setting_get --app=$app --key=max_upload_size) +#REMOVEME? disable_msisdn_registration=$(ynh_app_setting_get --app=$app --key=disable_msisdn_registration) +#REMOVEME? registrations_require_3pid=$(ynh_app_setting_get --app=$app --key=registrations_require_3pid) +#REMOVEME? allowed_local_3pids_email=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_email) +#REMOVEME? allowed_local_3pids_msisdn=$(ynh_app_setting_get --app=$app --key=allowed_local_3pids_msisdn) +#REMOVEME? account_threepid_delegates_msisdn=$(ynh_app_setting_get --app=$app --key=account_threepid_delegates_msisdn) +#REMOVEME? allow_guest_access=$(ynh_app_setting_get --app=$app --key=allow_guest_access) +#REMOVEME? default_identity_server=$(ynh_app_setting_get --app=$app --key=default_identity_server) +#REMOVEME? auto_join_rooms=$(ynh_app_setting_get --app=$app --key=auto_join_rooms) +#REMOVEME? autocreate_auto_join_rooms=$(ynh_app_setting_get --app=$app --key=autocreate_auto_join_rooms) +#REMOVEME? auto_join_rooms_for_guests=$(ynh_app_setting_get --app=$app --key=auto_join_rooms_for_guests) +#REMOVEME? enable_notifs=$(ynh_app_setting_get --app=$app --key=enable_notifs) +#REMOVEME? notif_for_new_users=$(ynh_app_setting_get --app=$app --key=notif_for_new_users) +#REMOVEME? enable_group_creation=$(ynh_app_setting_get --app=$app --key=enable_group_creation) -enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration) -turn_allow_guests=$(ynh_app_setting_get --app=$app --key=turn_allow_guests) -sso_enabled=$(ynh_app_setting_get --app=$app --key=sso_enabled) -password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled) -enable_3pid_lookup=$(ynh_app_setting_get --app=$app --key=enable_3pid_lookup) -push_include_content=$(ynh_app_setting_get --app=$app --key=push_include_content) +#REMOVEME? enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration) +#REMOVEME? turn_allow_guests=$(ynh_app_setting_get --app=$app --key=turn_allow_guests) +#REMOVEME? sso_enabled=$(ynh_app_setting_get --app=$app --key=sso_enabled) +#REMOVEME? password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled) +#REMOVEME? enable_3pid_lookup=$(ynh_app_setting_get --app=$app --key=enable_3pid_lookup) +#REMOVEME? push_include_content=$(ynh_app_setting_get --app=$app --key=push_include_content) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -104,10 +104,10 @@ fi #================================================= # MIGRATION 7 : Working config panel v1 #================================================= -backup_before_upgrade=$(ynh_app_setting_get --app=$app --key=backup_before_upgrade) +#REMOVEME? backup_before_upgrade=$(ynh_app_setting_get --app=$app --key=backup_before_upgrade) if [ -z $backup_before_upgrade ] ; then backup_before_upgrade="true" - disable_backup_before_upgrade=$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade) +#REMOVEME? disable_backup_before_upgrade=$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade) if [ "0$disable_backup_before_upgrade" -ne 0 ]; then backup_before_upgrade="false" fi @@ -118,20 +118,20 @@ fi # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -# We stop the service before to set ynh_clean_setup +#REMOVEME? # We stop the service before to set ynh_clean_setup ynh_systemd_action --service_name=matrix-$app.service --action=stop # Backup the current version of the app if $backup_before_upgrade ; then - ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 - ynh_backup_before_upgrade - ynh_clean_setup () { +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } else - ynh_script_progression --message="NOT Backing up the app before upgrading..." --weight=1 +#REMOVEME? ynh_script_progression --message="NOT Backing up the app before upgrading..." --weight=1 fi #================================================= @@ -142,10 +142,10 @@ fi # Migrate from settings 'special_domain' to 'domain' and 'special_path' to 'path' if [ -z $domain ]; then - domain=$(ynh_app_setting_get --app=$app --key=special_domain) - path_url=$(ynh_app_setting_get --app=$app --key=special_path) - ynh_app_setting_set --app=$app --key=domain --value=$domain - ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=special_domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=special_path) +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path ynh_app_setting_delete --app=$app --key=special_domain ynh_app_setting_delete --app=$app --key=special_path ynh_app_setting_set --app=$app --key=no_sso --value true @@ -154,7 +154,7 @@ fi # Define $server_name if not already defined if [ -z $server_name ]; then server_name=$domain - ynh_app_setting_set --app=$app --key=server_name --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=server_name --value=$domain fi # Define $jitsi_server if not already defined @@ -181,11 +181,11 @@ fi if [ -z $report_stats ]; then report_stats="false" - ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats +#REMOVEME? ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats fi if [ -z $is_free_registration ]; then - is_free_registration=$(ynh_app_setting_get --app=$app --key=is_""public) +#REMOVEME? is_free_registration=$(ynh_app_setting_get --app=$app --key=is_""public) fi if [ -z $synapse_user_app_pwd ]; then @@ -213,16 +213,16 @@ if [ -e "/var/lib/matrix-$app" ]; then fi mv "/var/lib/matrix-$app" "$data_path" fi -if ! grep -q "$final_path" /etc/passwd; then +if ! grep -q "$install_dir" /etc/passwd; then # matrix-synapse:x:994:994::/var/lib/matrix-synapse:/usr/sbin/nologin - sed --in-place -r "s@matrix-$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/matrix-$app\:/usr/sbin/nologin@matrix-$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd + sed --in-place -r "s@matrix-$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/matrix-$app\:/usr/sbin/nologin@matrix-$app\:x\:\1\:\:$install_dir\:/usr/sbin/nologin@g" /etc/passwd fi #================================================= # MIGRATION 7 : Working config panel v1 #================================================= -allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) +#REMOVEME? allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) if [ -z $allow_public_rooms ]; then allow_public_rooms="false" fi @@ -240,8 +240,8 @@ element_instance="element" if [ -z "$web_client_location" ] then if yunohost --output-as plain app list | grep -q "^$element_instance"'$'; then - element_domain=$(ynh_app_setting_get --app $element_instance --key domain) - element_path=$(ynh_app_setting_get --app $element_instance --key path) +#REMOVEME? element_domain=$(ynh_app_setting_get --app $element_instance --key domain) +#REMOVEME? element_path=$(ynh_app_setting_get --app $element_instance --key path) element_ynh_url="https://""$element_domain""$element_path" fi web_client_location=$element_ynh_url @@ -357,7 +357,7 @@ then ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled - ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled +#REMOVEME? ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup fi @@ -370,17 +370,17 @@ fi #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=6 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=6 # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -ynh_exec_warn_less ynh_install_app_dependencies $dependances +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $dependances #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] || [ ! -e $final_path/bin/python3 ] || [ ! -e $final_path/lib/python$python_version ] +if [ "$upgrade_type" == "UPGRADE_APP" ] || [ ! -e $install_dir/bin/python3 ] || [ ! -e $install_dir/lib/python$python_version ] then ynh_script_progression --message="Upgrading source files..." --weight=6 install_sources @@ -407,13 +407,13 @@ then # Go in virtualenvironnement set +u - source $final_path/bin/activate + source $install_dir/bin/activate set -u # Generate config and keys python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $server_name --report-stats=no -c homeserver.yml - # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does + # This function was defined when we called "source $install_dir/bin/activate". With this function we undo what "$install_dir/bin/activate" does set +u; deactivate set -u; @@ -464,11 +464,11 @@ then systemctl stop coturn.service # Set a port for each service in turnserver - turnserver_alt_tls_port=$(ynh_find_port --port=$((turnserver_tls_port+1))) - cli_port=$(ynh_find_port --port=5766) +#REMOVEME? turnserver_alt_tls_port=$(ynh_find_port --port=$((turnserver_tls_port+1))) +#REMOVEME? cli_port=$(ynh_find_port --port=5766) - ynh_app_setting_set --app=$app --key=turnserver_alt_tls_port --value=$turnserver_alt_tls_port - ynh_app_setting_set --app=$app --key=cli_port --value=$cli_port +#REMOVEME? ynh_app_setting_set --app=$app --key=turnserver_alt_tls_port --value=$turnserver_alt_tls_port +#REMOVEME? ynh_app_setting_set --app=$app --key=cli_port --value=$cli_port yunohost firewall allow Both $turnserver_alt_tls_port > /dev/null 2>&1 @@ -565,8 +565,8 @@ ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/cotu # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files -ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$final_path/Coturn_config_rotate.sh" -ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$final_path/update_synapse_for_appservice.sh" +ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$install_dir/Coturn_config_rotate.sh" +ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$install_dir/update_synapse_for_appservice.sh" # Ensure app-service folder has exists and the config file exit (Migration) mkdir -p /etc/matrix-$app/app-service @@ -613,14 +613,14 @@ ynh_add_fail2ban_config --use_template #================================================= # SETUP PERMISSIONS #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_legacy_permissions_delete_all +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_legacy_permissions_delete_all ynh_permission_url --permission=main --url=$domain/_matrix/cas_server.php/login --auth_header=true -ynh_permission_update --permission=main --show_tile=false --protected=true +#REMOVEME? ynh_permission_update --permission=main --show_tile=false --protected=true -if ! ynh_permission_exists --permission=server_api; then - ynh_permission_create --permission=server_api --url=$domain/_matrix \ +#REMOVEME? if ! ynh_permission_exists --permission=server_api; then +#REMOVEME? ynh_permission_create --permission=server_api --url=$domain/_matrix \ --label="Server access for client apps." --show_tile=false --allowed=visitors \ --auth_header=false --protected=true python3 remove_sso_conf_persistent.py $domain $server_name \ @@ -628,23 +628,23 @@ if ! ynh_permission_exists --permission=server_api; then else ynh_permission_url --permission=server_api --url=$domain/_matrix --remove_url=$server_name/.well-known/matrix \ --auth_header=false - ynh_permission_update --permission=server_api --label="Server access for client apps." --show_tile=false \ +#REMOVEME? ynh_permission_update --permission=server_api --label="Server access for client apps." --show_tile=false \ --protected=true fi -if yunohost --output-as plain domain list | grep -q "^$server_name"'$' && ! ynh_permission_exists --permission=server_client_infos; then - ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ +#REMOVEME? if yunohost --output-as plain domain list | grep -q "^$server_name"'$' && ! ynh_permission_exists --permission=server_client_infos; then +#REMOVEME? ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ --label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \ --auth_header=false --protected=true elif yunohost --output-as plain domain list | grep -q "^$server_name"'$'; then ynh_permission_url --permission=server_client_infos --url=$server_name/.well-known/matrix \ --auth_header=false - ynh_permission_update --permission=server_client_infos --label="Server info for clients. (well-known)" --show_tile=false \ +#REMOVEME? ynh_permission_update --permission=server_client_infos --label="Server info for clients. (well-known)" --show_tile=false \ --protected=true fi -if ! ynh_permission_exists --permission=admin_api; then - ynh_permission_create --permission=admin_api --url=$domain/_synapse \ +#REMOVEME? if ! ynh_permission_exists --permission=admin_api; then +#REMOVEME? ynh_permission_create --permission=admin_api --url=$domain/_synapse \ --label="Server administration API." --show_tile=false \ --auth_header=false --allowed=visitors fi @@ -655,9 +655,9 @@ fi # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -chown $synapse_user:root -R $final_path -chmod 770 $final_path/Coturn_config_rotate.sh -chmod 700 $final_path/update_synapse_for_appservice.sh +chown $synapse_user:root -R $install_dir +chmod 770 $install_dir/Coturn_config_rotate.sh +chmod 700 $install_dir/update_synapse_for_appservice.sh chown $synapse_user:root -R $data_path chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app