From 211dcec5453e1faf49f715c1c84506a83891827a Mon Sep 17 00:00:00 2001 From: eric_G <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:49:32 +0200 Subject: [PATCH] Testing (#13) * Update README.md * Cleaning up * Update manifest.json * Update change_url * Update manifest.json * [autopatch] Update issue and PR templates (#7) Co-authored-by: Yunohost-Bot <> * Fix * [autopatch] Update issue and PR templates (#8) Co-authored-by: Yunohost-Bot <> * Fix (#9) * Cleaning up * Update manifest.json * Auto-update README * Update manifest.json * 4.3 * Update restore * Fix * Auto-update README * Delete .DS_Store * Version 2 (#12) * v2 * Auto-update README * v2 * Auto-update README --------- Co-authored-by: yunohost-bot --------- Co-authored-by: YunoHost Bot Co-authored-by: Yunohost-Bot <> Co-authored-by: yunohost-bot --- README.md | 5 +-- README_fr.md | 23 ++++++------ check_process | 27 -------------- conf/nginx.conf | 2 +- doc/DESCRIPTION_fr.md | 2 +- manifest.json | 53 --------------------------- manifest.toml | 47 ++++++++++++++++++++++++ scripts/backup | 18 +--------- scripts/change_url | 84 +------------------------------------------ scripts/install | 72 +++---------------------------------- scripts/remove | 20 ----------- scripts/restore | 41 ++------------------- scripts/upgrade | 67 +++------------------------------- tests.toml | 7 ++++ 14 files changed, 84 insertions(+), 384 deletions(-) delete mode 100644 check_process delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/README.md b/README.md index 6d2c3cb..ea6927e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Slingcode for YunoHost -[![Integration level](https://dash.yunohost.org/integration/slingcode.svg)](https://dash.yunohost.org/appci/app/slingcode) ![Working status](https://ci-apps.yunohost.org/ci/badges/slingcode.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/slingcode.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/slingcode.svg)](https://dash.yunohost.org/appci/app/slingcode) ![Working status](https://ci-apps.yunohost.org/ci/badges/slingcode.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/slingcode.maintain.svg) + [![Install Slingcode with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=slingcode) *[Lire ce readme en français.](./README_fr.md)* @@ -28,7 +29,7 @@ Slingcode is a code editor contained in a single HTML file. Therefore, it has no - It's private. You only share what you choose. -**Shipped version:** 0.2.2~ynh4 +**Shipped version:** 0.2.2~ynh5 **Demo:** https://slingcode.net/slingcode.html diff --git a/README_fr.md b/README_fr.md index 81e93dd..59c9b75 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,19 +5,20 @@ It shall NOT be edited by hand. # Slingcode pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/slingcode.svg)](https://dash.yunohost.org/appci/app/slingcode) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/slingcode.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/slingcode.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/slingcode.svg)](https://dash.yunohost.org/appci/app/slingcode) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/slingcode.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/slingcode.maintain.svg) + [![Installer Slingcode avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=slingcode) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Slingcode rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +> *Ce package vous permet d’installer Slingcode rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* -## Vue d'ensemble +## Vue d’ensemble Slingcode est un éditeur de code contenu dans un unique fichier HTML. Il n'a pas de composant serveur, ce qui signifie que toutes vos données sont stockées dans le cache de votre navigateur. Cependant, il est toujours possible de créer des applications Web, de les exécuter, de les exporter et même de les partager en peer-to-peer. -### Caractéristiques: +### Caractéristiques : - Vous pouvez créer, exécuter et partager des applications Web avec. - Vous n'avez pas besoin d'outils compliqués pour l'utiliser, juste un navigateur Web. @@ -28,19 +29,19 @@ Slingcode est un éditeur de code contenu dans un unique fichier HTML. Il n'a pa - C'est privé. Vous ne partagez que ce que vous choisissez. -**Version incluse :** 0.2.2~ynh4 +**Version incluse :** 0.2.2~ynh5 **Démo :** https://slingcode.net/slingcode.html -## Captures d'écran +## Captures d’écran -![Capture d'écran de Slingcode](./doc/screenshots/Screenshot.png) +![Capture d’écran de Slingcode](./doc/screenshots/Screenshot.png) ## Documentations et ressources -* Site officiel de l'app : +* Site officiel de l’app : * Documentation officielle utilisateur : -* Dépôt de code officiel de l'app : +* Dépôt de code officiel de l’app : * Documentation YunoHost pour cette app : * Signaler un bug : @@ -56,4 +57,4 @@ ou sudo yunohost app upgrade slingcode -u https://github.com/YunoHost-Apps/slingcode_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/check_process b/check_process deleted file mode 100644 index 54dfc44..0000000 --- a/check_process +++ /dev/null @@ -1,27 +0,0 @@ -;; Test complet - auto_remove=1 - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - incorrect_path=1 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& - - \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 4924663..951cd65 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,7 +4,7 @@ location __PATH__/ { include /etc/nginx/mime.types; # Path to source - alias __FINALPATH__/ ; + alias __INSTALL_DIR__/ ; index slingcode.html; diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 12572fb..cde18a2 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1,6 +1,6 @@ Slingcode est un éditeur de code contenu dans un unique fichier HTML. Il n'a pas de composant serveur, ce qui signifie que toutes vos données sont stockées dans le cache de votre navigateur. Cependant, il est toujours possible de créer des applications Web, de les exécuter, de les exporter et même de les partager en peer-to-peer. -### Caractéristiques: +### Caractéristiques : - Vous pouvez créer, exécuter et partager des applications Web avec. - Vous n'avez pas besoin d'outils compliqués pour l'utiliser, juste un navigateur Web. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 6c7059e..0000000 --- a/manifest.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "Slingcode", - "id": "slingcode", - "packaging_format": 1, - "description": { - "en": "Browser based code editor in a single HTML file", - "fr": "Éditeur de code en ligne contenu dans un seul fichier HTML" - }, - "url": "https://slingcode.net/", - "version": "0.2.2~ynh4", - "upstream": { - "license": "MIT", - "website": "https://slingcode.net/", - "demo": "https://slingcode.net/slingcode.html", - "userdoc": "https://slingcode.net/screencasts.html", - "code": "https://github.com/chr15m/slingcode" - }, - "license": "MIT", - "maintainer": { - "name": "eric_G", - "email": "" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/slingcode", - "default": "/slingcode" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, Slingcode will be accessible by people who doesn’t have an account. This can be changed later via the webadmin.", - "fr": "Si cette case est cochée, Slingcode 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 new file mode 100644 index 0000000..2cf9c72 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,47 @@ +packaging_format = 2 + +id = "slingcode" +name = "Slingcode" +description.en = "Browser based code editor in a single HTML file" +description.fr = "Éditeur de code en ligne contenu dans un seul fichier HTML" + +version = "0.2.2~ynh5" + +maintainers = ["eric_G"] + +[upstream] +license = "MIT" +website = "https://slingcode.net/" +demo = "https://slingcode.net/slingcode.html" +userdoc = "https://slingcode.net/screencasts.html" +code = "https://github.com/chr15m/slingcode" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/slingcode" + + [install.init_main_permission] + type = "group" + default = "visitors" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/backup b/scripts/backup index 81edd20..a6b113b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -8,22 +8,6 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -33,7 +17,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" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index d0d606a..63210fa 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,94 +8,12 @@ source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up $app before changing its URL..." --weight=2 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # 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/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_change_url_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index b4b9642..e3b5949 100755 --- a/scripts/install +++ b/scripts/install @@ -8,52 +8,6 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= -# Retrieve arguments - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -# Copy files to the right place -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=2 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -61,14 +15,11 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +mkdir -p $install_dir +cp -a ../sources/slingcode.html $install_dir/slingcode.html -mkdir -p $final_path -cp -a ../sources/slingcode.html $final_path/slingcode.html - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -78,21 +29,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 2123569..2952ff1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -8,26 +8,6 @@ source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=3 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 33381f2..ea0195c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,32 +8,6 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -42,24 +16,15 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring $app main directory..." --weight=2 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d5331b8..968af76 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,63 +8,12 @@ source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -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 - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up $app before upgrading..." --weight=3 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -74,13 +23,12 @@ then ynh_script_progression --message="Upgrading source files..." --weight=4 # Download from ../sources - mkdir -p $final_path - cp -a ../sources/slingcode.html $final_path/slingcode.html + mkdir -p $install_dir + cp -a ../sources/slingcode.html $install_dir/slingcode.html fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -90,13 +38,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -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..91daf17 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ \ No newline at end of file