From 05f2b3e496179c5faf724c4892efa0eb33bfad0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 6 Jun 2023 22:15:04 +0200 Subject: [PATCH] v2 --- conf/armv7_bookworm.src | 7 --- conf/armv7_bullseye.src | 7 --- manifest.toml | 72 ++++++++++++++++++++++ scripts/_common.sh | 40 ++++++------- scripts/backup | 16 ++--- scripts/change_url | 68 ++++++++++----------- scripts/install | 88 +++++++++++++-------------- scripts/remove | 32 +++++----- scripts/restore | 58 +++++++++--------- scripts/upgrade | 128 ++++++++++++++++++++-------------------- 10 files changed, 288 insertions(+), 228 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 5bef691..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.84.1/matrix-synapse_1.84.1-bookworm-bin1_armv7l.tar.gz -SOURCE_SUM=fd516b379687540aa74c828a8d93cb05e59a04c03508258cfb6b331cfb80ea18 -# (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 1b5e931..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.84.1/matrix-synapse_1.84.1-bullseye-bin1_armv7l.tar.gz -SOURCE_SUM=70ea244b3527ccaaba5384106078c60ef1482b104924311af02406bd52eebf3c -# (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..d51b8ed --- /dev/null +++ b/manifest.toml @@ -0,0 +1,72 @@ +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.84.1~ynh2" + +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.0.11" +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" + full_domain = true + + [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.84.1/matrix-synapse_1.84.1-bookworm-bin1_armv7l.tar.gz" + sha256 = "fd516b379687540aa74c828a8d93cb05e59a04c03508258cfb6b331cfb80ea18" + + [resources.sources.armv7_bullseye] + url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.84.1/matrix-synapse_1.84.1-bullseye-bin1_armv7l.tar.gz" + sha256 = "70ea244b3527ccaaba5384106078c60ef1482b104924311af02406bd52eebf3c" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] diff --git a/scripts/_common.sh b/scripts/_common.sh index 83fd3d9..8e13a2f 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,50 +1,50 @@ 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; if [ $(lsb_release --codename --short) == "bullseye" ]; then # Fix issue with setuptools https://github.com/pypa/setuptools/issues/3118 @@ -56,7 +56,7 @@ install_sources() { 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 d29754c..0092b05 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 @@ -43,12 +43,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) @@ -60,11 +60,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')" @@ -75,17 +75,17 @@ 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=no_sso --value true 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=is_free_registration --value=$is_free_registration -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=allow_public_rooms --value=$allow_public_rooms 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 @@ -98,11 +98,11 @@ ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_ 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 @@ -110,11 +110,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 @@ -135,18 +135,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 @@ -160,13 +160,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;" @@ -208,13 +208,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; @@ -327,27 +327,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 @@ -367,9 +367,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 c2626ce..675e663 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 e48f9d8..4eaa54d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,36 +11,36 @@ 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) -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? 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? 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) domain_whitelist_client_=$(get_domain_list) domain_whitelist_client=${domain_whitelist_client_%"\n"} main_domain=$(yunohost domain list --output-as json | jq -r .main) @@ -73,19 +73,19 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 -# 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 [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] +#REMOVEME? if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] then - ynh_backup_before_upgrade - ynh_clean_setup () { +#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 } fi @@ -97,10 +97,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 @@ -109,7 +109,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 @@ -126,7 +126,7 @@ 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 $allow_public_rooms ]; then @@ -135,7 +135,7 @@ if [ -z $allow_public_rooms ]; then 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) ynh_app_setting_set --app=$app --key=is_free_registration --value=$is_free_registration fi @@ -164,25 +164,25 @@ 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 #================================================= # 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 @@ -209,13 +209,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; @@ -275,11 +275,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 @@ -375,8 +375,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 @@ -423,14 +423,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 \ @@ -438,23 +438,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 @@ -465,9 +465,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