From 6eca76cc89f671bb5f74e79afa3edd39cb0c3381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 10 Mar 2023 08:19:05 +0100 Subject: [PATCH] v2 --- manifest.json | 56 ------------------------------ manifest.toml | 33 +++++++++--------- scripts/_common.sh | 2 -- scripts/backup | 19 ----------- scripts/change_url | 85 +--------------------------------------------- scripts/install | 67 +----------------------------------- scripts/remove | 32 ----------------- scripts/upgrade | 64 ---------------------------------- tests.toml | 0 9 files changed, 18 insertions(+), 340 deletions(-) delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 9ffaaee..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~ynh1", - "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/manifest.toml b/manifest.toml index 9d9cd1e..09387b4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,28 +7,25 @@ description.fr = "Admin UI pour Synapse" version = "0.8.7~ynh1" -maintainers = [] +maintainers = ["eric_G"] [upstream] license = "Apache-2.0" code = "https://github.com/Awesome-Technologies/synapse-admin" website = "https://github.com/Awesome-Technologies/synapse-admin" -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.1.14" -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"] +architectures = "all" multi_instance = false -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, ... +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" full_domain = true @@ -47,10 +44,11 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen default = "visitors" [resources] - [resources.sources.main] - url = "https://github.com/Awesome-Technologies/synapse-admin/releases/download/0.8.7/synapse-admin-0.8.7-dirty.tar.gz" - sha256 = "3f74cbfec0a3b14b5684d1bded4816a7946d2e9b88b7186767189c14811224e9" + [resources.sources.main] + url = "https://github.com/Awesome-Technologies/synapse-admin/releases/download/0.8.7/synapse-admin-0.8.7-dirty.tar.gz" + sha256 = "3f74cbfec0a3b14b5684d1bded4816a7946d2e9b88b7186767189c14811224e9" + [resources.ports] [resources.system_user] @@ -58,7 +56,8 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" - [[resources.apt.extras]] - repo = "deb https://dl.yarnpkg.com/debian/ stable main" - key = "https://dl.yarnpkg.com/debian/pubkey.gpg" - packages = "yarn" + + [[resources.apt.extras]] + extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main" + extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg" + extras.yarn.packages = "yarn" diff --git a/scripts/_common.sh b/scripts/_common.sh index a70846c..b818f0f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,8 +4,6 @@ # COMMON VARIABLES #================================================= -version_commit="9b43d41040b79cc8ad240dbadc66098bc8231c2b" - nodejs_version=16 #================================================= diff --git a/scripts/backup b/scripts/backup index c39d0e6..70268d1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,25 +9,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? synapse_app=$(ynh_app_setting_get --app=$app --key=synapse_app) -#REMOVEME? synapse_domain=$(ynh_app_setting_get --app=$app --key=synapse_domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index c2963ff..f1ba7b7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,60 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up $app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -77,29 +23,7 @@ ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" #================================================= ynh_script_progression --message="Updating Nginx web server configuration..." --weight=1 -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -#REMOVEME? # Change the path in the nginx config file -if [ $change_path -eq 1 ] -then -#REMOVEME? # Make a backup of the original nginx config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" -#REMOVEME? # Set global variables for nginx helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" -#REMOVEME? # Create a dedicated nginx config -#REMOVEME? ynh_add_nginx_config -fi - -#REMOVEME? # Change the domain for nginx -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -111,13 +35,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index c917579..c2a332d 100644 --- a/scripts/install +++ b/scripts/install @@ -9,37 +9,14 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -path="/" -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? synapse_app=$YNH_APP_ARG_SYNAPSE_APP #REMOVEME? synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain) #REMOVEME? synapse_port=$(ynh_app_setting_get --app=$synapse_app --key=synapse_port) -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= @@ -51,46 +28,22 @@ ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app #REMOVEME? ynh_app_setting_set --app=$app --key=synapse_domain --value=$synapse_domain #REMOVEME? ynh_app_setting_set --app=$app --key=synapse_port --value=$synapse_port -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=2 - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=9090) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - #================================================= # INSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=20 +ynh_script_progression --message="Installing dependencies..." --weight=20 # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$install_dir -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -158,24 +111,6 @@ 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" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary or protect it -#REMOVEME? if [ $is_public -eq 1 ] -then -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 282dca7..42605b9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? synapse_app=$(ynh_app_setting_get --app=$app --key=synapse_app) -#REMOVEME? synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain) - #================================================= # STANDARD REMOVE #================================================= @@ -54,19 +41,10 @@ ynh_remove_logrotate #================================================= # REMOVE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_nodejs -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=6 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -78,16 +56,6 @@ ynh_secure_remove --file="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.co # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8fb7c52..1fa4559 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,39 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? synapse_app=$(ynh_app_setting_get --app=$app --key=synapse_app) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=20 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -51,24 +24,6 @@ if ynh_compare_current_package_version --comparison le --version 0.8.3~ynh2 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 -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? 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 - -# Reload and store Synapse's settings, in case of they changed -#REMOVEME? synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain) -#REMOVEME? synapse_port=$(ynh_app_setting_get --app=$synapse_app --key=synapse_port) -#REMOVEME? ynh_app_setting_set --app=$app --key=synapse_domain --value=$synapse_domain -#REMOVEME? ynh_app_setting_set --app=$app --key=synapse_port --value=$synapse_port #================================================= # STANDARD UPGRADE STEPS @@ -79,14 +34,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -98,7 +45,6 @@ then ynh_setup_source --dest_dir="$install_dir" --keep=".env" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -121,9 +67,6 @@ ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - #================================================= # SPECIFIC UPGRADE #============================================== @@ -172,13 +115,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" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..e69de29