diff --git a/README.md b/README.md index 9ca1f2e..eaf6314 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Synapse-admin is an Admin UI for Matrix Synapse homeserver. +<<<<<<< HEAD **Shipped version:** 0.8.7~ynh2 +======= +**Shipped version:** 0.8.7~ynh1 +>>>>>>> parent of ec2cc1d (Merge branch 'testing' into version-2) ## Screenshots diff --git a/README_fr.md b/README_fr.md index 6f39ecc..8255298 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,11 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Synapse-admin is an Admin UI for Matrix Synapse homeserver. +<<<<<<< HEAD **Version incluse :** 0.8.7~ynh2 +======= +**Version incluse :** 0.8.7~ynh1 +>>>>>>> parent of ec2cc1d (Merge branch 'testing' into version-2) ## Captures d’écran diff --git a/check_process b/check_process deleted file mode 100644 index e2b820a..0000000 --- a/check_process +++ /dev/null @@ -1,28 +0,0 @@ -;; Test complet - ; pre-install - sudo yunohost tools update apps - sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/tree/823f98a8cbe108ad4cc0e38e280a83401dca2b9f -a "domain=sub.domain.tld&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force - ; Manifest - domain="domain.tld" - synapse_app="synapse" - synapse_domain="sub.domain.tld" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=4eaa242f11e8e9c6ed7afbb7cdf07fd95f8d04a1 - backup_restore=1 - multi_instance=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=4eaa242f11e8e9c6ed7afbb7cdf07fd95f8d04a1 - name=Upgrade from 0.8.5~ynh5 and remove app build - manifest_arg=domain=DOMAIN&synapse_app=synapse&synapse_domain=sub.domain.tld& diff --git a/conf/.env b/conf/.env new file mode 100644 index 0000000..3be4fc3 --- /dev/null +++ b/conf/.env @@ -0,0 +1,8 @@ +# This setting allows to fix the homeserver. +# If you set this setting, the user will not be able to select +# the server and have to use synapse-admin with this server. + +REACT_APP_SERVER=https://__SYNAPSE_DOMAIN__ + +#Define the port to avoid collisions on port 3000 +PORT=__PORT__ diff --git a/conf/nginx.conf b/conf/nginx.conf index 0ac62b9..0880bcd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,19 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - alias __FINAL_PATH__/; + proxy_pass http://127.0.0.1:__PORT__; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; - index index.html; - try_files $uri $uri/ /index.html; + client_max_body_size 50M; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 86a2ca2..0000000 --- a/manifest.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "Synapse Admin", - "id": "synapse-admin", - "packaging_format": 1, - "description": { - "en": "Admin UI for Synapse", - "fr": "Admin UI pour Synapse" - }, - "version": "0.8.7~ynh2", - "url": "https://github.com/Awesome-Technologies/synapse-admin", - "upstream": { - "license": "Apache-2.0", - "code": "https://github.com/Awesome-Technologies/synapse-admin" - }, - "license": "Apache-2.0", - "maintainer": { - "name": "" - }, - "requirements": { - "yunohost": ">= 11.1.14" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "synapse_app", - "type": "string", - "ask": { - "en": "Input the Synapse app ID you wish to connect to.", - "fr": "Entrez l'ID de l'app Synapse à laquelle vous souhaitez vous connecter." - }, - "help": { - "en": "Leave the default value if you have only one Synapse server installed.", - "fr": "Laissez la valeur par défaut si vous n'avez installé qu'un seul serveur Synapse." - }, - "default": "synapse" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, Synapse Admin will be accessible by people who do not have an account. This can be changed later via the webadmin.", - "fr": "Si cette case est cochée, Synapse Admin sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, - "default": true - } - ] - } -} diff --git a/scripts/_common.sh b/scripts/_common.sh index a03f47e..b818f0f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,11 +4,8 @@ # COMMON VARIABLES #================================================= -<<<<<<< HEAD nodejs_version=16 -======= ->>>>>>> testing #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 1b290e6..70268d1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -27,6 +27,18 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 4e09eb5..fb3d33c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,6 +11,13 @@ source /usr/share/yunohost/helpers #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" + #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -21,11 +28,12 @@ ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION #================================================= -# RELOAD NGINX +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +# Start a systemd service +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 1f745eb..7b92c62 100644 --- a/scripts/install +++ b/scripts/install @@ -24,7 +24,13 @@ ynh_app_setting_set --app=$app --key=synapse_domain --value=$synapse_domain ynh_app_setting_set --app=$app --key=synapse_port --value=$synapse_port #================================================= -# STANDARD MODIFICATIONS +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=20 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -50,15 +56,55 @@ ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d #================================================= # SPECIFIC SETUP #============================================== -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +# INSTALL SYNAPSE-ADMIN +#============================================== +ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20 -# Make app public if necessary or protect it -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission="main" --add="visitors" -fi +pushd "$install_dir" + ynh_use_nodejs + ynh_exec_warn_less yarn install + ynh_exec_warn_less yarn build +popd + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" + +chown -R $app:www-data "$install_dir" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + +env_path="$PATH" +ynh_add_systemd_config + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=1 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "UI admin for Synapse" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=2 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #--line_match="HTTP Server listening" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 4d96c09..42605b9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,13 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain) - #================================================= # STANDARD REMOVE #================================================= @@ -30,12 +23,27 @@ then fi #================================================= -# REMOVE APP MAIN DIR +# STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=6 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 -# Remove the app directory securely -ynh_secure_remove --file="$final_path" +# Remove the dedicated systemd config +ynh_remove_systemd_config + +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# REMOVE DEPENDENCIES +#================================================= + +# Remove metapackage and its dependencies +ynh_remove_nodejs #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index e3bfe87..105d683 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,6 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -<<<<<<< HEAD # SPECIFIC RESTORATION #================================================= @@ -67,8 +66,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #--line_match="HTTP Server listening" #================================================= -======= ->>>>>>> testing # GENERIC FINALIZATION #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index 06e2398..3254d26 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,49 +25,24 @@ then ynh_die --message="Upgrade from version 0.8.3 is not possible. You must uninstall and reinstall Synapse-admin package manually" fi -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# If synapse_app doesn't exist, create it and assume it is `synapse` -if [ -z "$synapse_app" ]; then - synapse_app="synapse" - ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app -fi - -# Delete service and nodejs dependencies -if ynh_compare_current_package_version --comparison lt --version 0.8.7~ynh1 -then - ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" - yunohost service remove $app - ynh_remove_nodejs - ynh_remove_logrotate - ynh_remove_app_dependencies - - ynh_app_setting_delete --app=$app --key=synapse_port - ynh_app_setting_delete --app=$app --key=port -fi - -# Reload and store Synapse's settings, in case of they changed -synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain) -synapse_port=$(ynh_app_setting_get --app=$synapse_app --key=synapse_port) -ynh_app_setting_set --app=$app --key=synapse_domain --value=$synapse_domain -ynh_app_setting_set --app=$app --key=synapse_port --value=$synapse_port - #================================================= # STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=2 + ynh_script_progression --message="Upgrading source files..." --weight=16 - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" --keep=".env" fi chmod -R o-rwx "$install_dir" @@ -76,7 +51,7 @@ chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -84,6 +59,62 @@ ynh_add_nginx_config # Create NGINX config to access /_synapse/admin endpoint ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=18 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# SPECIFIC UPGRADE +#============================================== +# INSTALL CODIMD +#============================================== +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20 + + pushd "$install_dir" + ynh_use_nodejs + ynh_exec_warn_less yarn install + ynh_exec_warn_less yarn build + popd +fi + +#================================================= +# ADD A CONFIGURATION +#================================================= +#ynh_script_progression --message="Adding a configuration file..." --weight=1 + +#ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" + +#chown -R $app:www-data "$install_dir" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=2 + +env_path="$PATH" +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "UI admin for Synapse" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action=start --log_path=systemd #--line_match="HTTP Server listening" + #================================================= # END OF SCRIPT #=================================================