From bc583da1a39b16ac6f820427313dfd23944f5aa4 Mon Sep 17 00:00:00 2001 From: lapineige Date: Wed, 6 May 2020 11:03:27 +0200 Subject: [PATCH 01/67] Allow PDF export by default --- conf/config.json.example | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/config.json.example b/conf/config.json.example index 6143584..804fab8 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -7,6 +7,7 @@ "loglevel": "info", "useCDN": false, "allowGravatar": false, + "allowPDFExport": true, "hsts": { "enable": true, "maxAgeSeconds": 31536000, From eef6a1ef3ca2fe7e19570ea3803104619fce683b Mon Sep 17 00:00:00 2001 From: lapineige Date: Wed, 6 May 2020 11:05:04 +0200 Subject: [PATCH 02/67] Add advanced configuration documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 60c73bb..3153c1e 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,7 @@ Links: ![](https://demo.codimd.org/screenshot.png) +### Advanced configuration + +If you need to configure your CodiMD, you can tweak your `config.json` file, using this documentation: https://github.com/codimd/server/blob/master/docs/configuration-config-file.md From 40933628a1a2347dbe93354e7341e9508dc4d1d1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 12:49:24 +0200 Subject: [PATCH 03/67] fix --- README.md | 78 +++++-- README_fr.md | 71 ++++++ conf/.sequelizerc.example | 3 +- conf/app.src | 2 +- conf/config.json.example | 17 +- conf/nginx.conf | 9 +- conf/systemd.service | 7 +- manifest.json | 21 +- ...{ynh_add_extra_apt_repos__3 => _common.sh} | 81 ++----- scripts/backup | 91 ++++++++ scripts/change_url | 128 +++++++++++ scripts/install | 154 +++++++------ scripts/remove | 66 +++--- scripts/restore | 141 ++++++++++++ scripts/upgrade | 216 ++++++++++++++++++ 15 files changed, 881 insertions(+), 204 deletions(-) create mode 100644 README_fr.md rename scripts/{ynh_add_extra_apt_repos__3 => _common.sh} (73%) create mode 100644 scripts/backup create mode 100644 scripts/change_url create mode 100644 scripts/restore create mode 100644 scripts/upgrade diff --git a/README.md b/README.md index 3153c1e..e307507 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,70 @@ # CodiMD for YunoHost -A collaborative editor to work on notes written in Markdown +[![Integration level](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) +[![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allow you to install CodiMD quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview + +Collaborative editor to work on notes written in Markdown. **Shipped version:** 1.6.0 -**Status**: In progress, do *not* consider this app as stable and fully working (yet) - -**To be implemented**: -- Upgrade (right now you need to remove the app and install its new version - your documents are likely to be lost…) -- Backup and restore system - -Links: -- [Yunohost project](https://yunohost.org) -- [CodiMD website](https://github.com/codimd/server/) -- [Demo](https://demo.codimd.org/) - -[![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) - - -### Screenshot +## Screenshots ![](https://demo.codimd.org/screenshot.png) -### Advanced configuration +## Demo -If you need to configure your CodiMD, you can tweak your `config.json` file, using this documentation: https://github.com/codimd/server/blob/master/docs/configuration-config-file.md +* [Official demo](https://demo.codimd.org/) +## Configuration + +If you need to configure CodiMD, you can tweak /var/www/codimd/config.json file using this [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) + +## Documentation + + * Official documentation: https://hackmd.io/c/codimd-documentation/ + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Multi-users support + +* Is LDAP supported? No +* Can the app be used by multiple users? Yes + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) + +## Limitations + +**Status**: In progress, do *not* consider this app as stable and fully working (yet) + +## Additional information + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/codimd_ynh/issues + * Upstream app repository: https://github.com/codimd/server/ + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +or +sudo yunohost app upgrade codimd -u https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..593a25a --- /dev/null +++ b/README_fr.md @@ -0,0 +1,71 @@ +# CodiMD pour YunoHost + +[![Niveau d’intégration](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) +[![Installer CodiMD avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d’installer CodiMD 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 +Éditeur collaboratif pour travailler sur des notes en Markdown. + +**Version incluse:** 1.6.0 + +## Captures d’écran + +![](https://demo.codimd.org/screenshot.png) + +## Démo + +* [Démo officielle](https://demo.codimd.org/) + +## Configuration + +Français + +Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier /var/www/codimd/config.json en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) + +## Documentation + + * Documentation officielle : https://hackmd.io/c/codimd-documentation/ + * Documentation YunoHost : Si une documentation spécifique est nécessaire, n’hésitez pas à contribuer. + +## Caractéristiques spécifiques YunoHost + +#### Support multi-utilisateurs + +* L’authentification LDAP est-elle prise en charge ? Non +* L’application peut-elle être utilisée par plusieurs utilisateurs ? Oui + +#### Architectures supportées + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) + +## Limitations + +**Statut** : En cours, ne *pas encore* considérer cette application comme stable et fonctionnant. + +## Informations additionnelles + +## Liens + + * Signaler un bug : https://github.com/YunoHost-Apps/codimd_ynh/issues + * Dépôt de l’application principale : https://github.com/codimd/server/ + * Site web YunoHost : https://yunohost.org/ + +--- + +Informations pour les développeurs +---------------- + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +ou +sudo yunohost app upgrade codimd -u https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +``` diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 1f7606c..29b59f2 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -1,9 +1,8 @@ - var path = require('path'); module.exports = { 'config': path.resolve('config.json'), 'migrations-path': path.resolve('lib', 'migrations'), 'models-path': path.resolve('lib', 'models'), - 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' + 'url': 'mysql://__DB_USER__:__DB_PASS__@localhost:3306/__DB_NAME__' } diff --git a/conf/app.src b/conf/app.src index bb9317d..10abb29 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=3639eaf70a37ee0513c75259c70b3d0c2c10116e9b2989dc9c571f98017120bd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=codimd.tar.gz +SOURCE_FILENAME=codimd.tar.gz \ No newline at end of file diff --git a/conf/config.json.example b/conf/config.json.example index 804fab8..3961f8d 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -1,4 +1,3 @@ - { "production": { "protocolUseSSL": true, @@ -7,7 +6,7 @@ "loglevel": "info", "useCDN": false, "allowGravatar": false, - "allowPDFExport": true, + "allowPDFExport": false, "hsts": { "enable": true, "maxAgeSeconds": 31536000, @@ -21,15 +20,19 @@ "upgradeInsecureRequests": "auto", "addDefaults": true, "addDisqus": true, - "addGoogleAnalytics": true + "addGoogleAnalytics": false }, "db": { "username": "__DB_USER__", "password": "__DB_PASS__", "database": "__DB_NAME__", "host": "localhost", - "port": "5432", - "dialect": "postgres" - } + "port": "3306", + "dialect": "mysql" + }, +# "github": { +# "clientID": "YOUR_clientID", +# "clientSecret": "YOUR_clientSecret" +# } } -} +} \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 3c181aa..747be58 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,7 +4,7 @@ location ^~ / { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass http://127.0.0.1:__PORT__; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -15,4 +15,11 @@ location ^~ / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; + + # setup for image upload + client_max_body_size 8192m; + proxy_max_temp_file_size 8192m; + + proxy_read_timeout 300; + proxy_connect_timeout 300; } diff --git a/conf/systemd.service b/conf/systemd.service index 7113896..7b1b7e5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,16 +1,17 @@ [Unit] Description=__APP__ daemon -After=syslog.target network.target +After=network.target +After=mysql.service [Service] Type=simple -User=__APP__ -Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" ExecStart=/usr/bin/yarn start Restart=always +PrivateTmp=true +PrivateDevices=true [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index edeb428..b11d2b8 100644 --- a/manifest.json +++ b/manifest.json @@ -3,21 +3,22 @@ "id": "codimd", "packaging_format": 1, "description": { - "en": "A collaborative editor to work on notes written in Markdown", - "fr": "Un éditeur collaboratif pour travailler sur des notes en Markdown" + "en": "Collaborative editor to work on notes written in Markdown", + "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, "version": "1.6.0~ynh1", "url": "https://github.com/codimd/server", - "license": "AGPL-v3", + "license": "AGPL-3.0-only", "maintainer": { "name": "liberodark" }, "requirements": { - "yunohost": ">= 3.6" + "yunohost": ">= 3.7.0" }, - "multi_instance": false, + "multi_instance": true, "services": [ - "nginx" + "nginx", + "mysql" ], "arguments": { "install": [{ @@ -27,15 +28,19 @@ "en": "Choose a domain name for CodiMD", "fr": "Choisissez un nom de domaine pour CodiMD" }, - "example": "example.com" + "example": "codimd.domaim.org" }, { "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public site ?", + "en": "Is it a public site?", "fr": "Est-ce un site public ?" }, + "help": { + "en": "If enabled, CodiMD 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, CodiMD sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + }, "default": true } ] diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/_common.sh similarity index 73% rename from scripts/ynh_add_extra_apt_repos__3 rename to scripts/_common.sh index 3784020..2915c8e 100644 --- a/scripts/ynh_add_extra_apt_repos__3 +++ b/scripts/_common.sh @@ -1,5 +1,23 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="apt-transport-https" + +nodejs_version="10" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= +#!/bin/bash + # Pin a repository. # # usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] @@ -36,8 +54,8 @@ ynh_pin_repo () { mkdir -p "/etc/apt/preferences.d" echo "Package: $package -Pin: $pin -Pin-Priority: $priority" \ + Pin: $pin + Pin-Priority: $priority" \ | $append "/etc/apt/preferences.d/$name" } @@ -209,65 +227,6 @@ ynh_install_extra_app_dependencies () { ynh_remove_extra_repo --name="$app" } -#================================================= - -# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies - -# Define and install dependencies with a equivs control file -# This helper can/should only be called once per app -# -# usage: ynh_install_app_dependencies dep [dep [...]] -# | arg: dep - the package name to install in dependence -# You can give a choice between some package with this syntax : "dep1|dep2" -# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" -# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) -# -# Requires YunoHost version 2.6.4 or higher. -ynh_install_app_dependencies () { - local dependencies=$@ - dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" - dependencies=${dependencies//|/ | } - local manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - - local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. - if [ ${#version} -eq 0 ]; then - version="1.0" - fi - local dep_app=${app//_/-} # Replace all '_' by '-' - - # Handle specific versions - if [[ "$dependencies" =~ [\<=\>] ]] - then - # Replace version specifications by relationships syntax - # https://www.debian.org/doc/debian-policy/ch-relationships.html - # Sed clarification - # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. - # [\<=\>] matches < = or > - # \+ matches one or more occurence of the previous characters, for >= or >>. - # [^,]\+ matches all characters except ',' - # Ex: package>=1.0 will be replaced by package (>= 1.0) - dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" - fi - - cat > /tmp/"${dep_app}"-ynh-deps.control << EOF # Make a control file for equivs-build -Section: misc -Priority: optional -Package: ${dep_app}-ynh-deps -Version: ${version} -Depends: ${dependencies} -Architecture: all -Description: Fake package for $app (YunoHost app) dependencies - This meta-package is only responsible of installing its dependencies. -EOF - ynh_package_install_from_equivs /tmp/"${dep_app}"-ynh-deps.control \ - || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies - rm /tmp/"${dep_app}"-ynh-deps.control - ynh_app_setting_set --app="$app" --key=apt_dependencies --value="$dependencies" -} - ynh_add_app_dependencies () { # Declare an array to define the options of this helper. local legacy_args=pr diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..9a1989f --- /dev/null +++ b/scripts/backup @@ -0,0 +1,91 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +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) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$(ynh_app_setting_get --app=$app --key=db_user) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=2 + +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Backing up the main app directory..." --weight=1 + +ynh_backup --src_path="$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Backing up Nginx web server configuration..." --weight=1 + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Backing up the MySQL database..." --weight=1 + +ynh_mysql_dump_db --database="$db_name" > db.sql + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= +ynh_script_progression --message="Backing up logrotate configuration..." --weight=2 + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= +ynh_script_progression --message="Backing up systemd configuration..." --weight=1 + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# 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 +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..9702a07 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,128 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +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) + +# Add settings here as needed by your application +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1 + +# 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 + +#================================================= +# 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="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 + +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 + +#================================================= +# GENERIC FINALISATION +#================================================= +# 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" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 98b906d..6b2a705 100644 --- a/scripts/install +++ b/scripts/install @@ -6,13 +6,17 @@ # IMPORT GENERIC HELPERS #================================================= -source ynh_add_extra_apt_repos__3 +source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -20,15 +24,16 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME + domain=$YNH_APP_ARG_DOMAIN path_url="/" 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..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -36,151 +41,148 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path ynh_webpath_register "$app" "$domain" $path_url -port=$(ynh_find_port 3000) +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." --weight=2 -db_user=$app -db_name=$app -db_pass=$(ynh_string_random 20) +# Find an available port +port=$(ynh_find_port --port=3002) +ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" path $path_url -ynh_app_setting_set "$app" is_public "$is_public" -ynh_app_setting_set "$app" port "$port" -ynh_app_setting_set "$app" db_pass "$db_pass" -ynh_app_setting_set "$app" final_path "$final_path" +ynh_app_setting_set --app="$app" --key="domain" --value="$domain" +ynh_app_setting_set --app="$app" --key="path" --value="$path_url" +ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" +ynh_app_setting_set --app="$app" --key="final_path" --value="$final_path" #============================================== -# INSTALL POSTGRES +# INSTALL DEPENDENCIES #============================================== -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=20 -ynh_install_app_dependencies postgresql apt-transport-https +ynh_install_app_dependencies $pkg_dependencies + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_install_nodejs 10 - #============================================== # CREATE DB #============================================== -ynh_script_progression --message="Creating a database..." +ynh_script_progression --message="Creating a database..." --weight=2 -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pass" +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" +ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=2 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring nginx web server..." --weight=2 + +# Create a dedicated nginx config +ynh_add_nginx_config #================================================= # MODIFY A CONFIG FILE #================================================= # Main config File -ynh_replace_string "__PORT__" "$port" "../conf/config.json.example" -ynh_replace_string "__DOMAIN__" "$domain" "../conf/config.json.example" -ynh_replace_string "__PATH__" "${path_url:1}" "../conf/config.json.example" -ynh_replace_string "__DB_USER__" "$db_user" "../conf/config.json.example" -ynh_replace_string "__DB_NAME__" "$db_name" "../conf/config.json.example" -ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/config.json.example" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path"/config.json ynh_store_file_checksum "$final_path/config.json" # DB Config File -ynh_replace_string "__DB_USER__" "$db_user" "../conf/.sequelizerc.example" -ynh_replace_string "__DB_NAME__" "$db_name" "../conf/.sequelizerc.example" -ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc #============================================== # INSTALL CODIMD #============================================== -ynh_script_progression --message="Building application... (this will take some time and resources!)" +ynh_script_progression --message="Building application... (this will take some time and resources!)" --weight=240 -pushd "$final_path" || exit +pushd "$final_path" || ynh_die -# ---- This is copypasta from https://raw.githubusercontent.com/codimd/server/master/bin/setup -if [ ! -f config.json ]; then - cp config.json.example config.json -fi +yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build -if [ ! -f .sequelizerc ]; then - cp .sequelizerc.example .sequelizerc -fi - -yarn install --non-interactive -yarn install --non-interactive --production=false # FIXME: this doesn't sounds like what we want to have for a real deployment ? idk -# ---- End copypasta from https://raw.githubusercontent.com/codimd/server/master/bin/setup - -yarn run build -#node_modules/.bin/sequelize db:migrate -popd || exit +popd || ynh_die #================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring nginx web server..." - -# Create a dedicated nginx config -ynh_add_nginx_config - +# GENERIC FINALIZATION #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user ynh_system_user_create "$app" + chown -R "$app":"$app" "$final_path" +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=2 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" -ynh_replace_string "__APP__" "$app" "../conf/systemd.service" -ynh_replace_string "__FINALPATH__" "$final_path" "../conf/systemd.service" -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" ynh_add_systemd_config -yunohost service add "$app" --description "CodiMD daemon" +yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Starting $app..." --weight=2 -ynh_script_progression --message="Starting $app..." - -ynh_systemd_action --service_name="$app" --action="start" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 -ynh_script_progression --message="Configuring SSOwat..." - -# If app is public, add url to SSOWat conf as skipped_uris -if [ "$is_public" -eq 1 ]; then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" -fi +# 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..." +ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 1c60fab..1c13051 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,85 +6,97 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -db_name=$app -db_user=$app -final_path=$(ynh_app_setting_get "$app" final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL -#================================================= - -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status "$app" >/dev/null 2>&1 -then - ynh_script_progression --message="Removing $app service" - yunohost service remove "$app" -fi - #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config #================================================= -# REMOVE THE POSTGRESQL DATABASE +# REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database" +ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db "$db_name" "$db_name" +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies" +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies +ynh_remove_nodejs + #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory" +ynh_script_progression --message="Removing app main directory..." --weight=6 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration" +ynh_script_progression --message="Removing Nginx web server configuration..." --weight=5 # Remove the dedicated nginx config ynh_remove_nginx_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # GENERIC FINALIZATION +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + ynh_script_progression --message="Closing port $port..." --weight=1 + ynh_exec_warn_less yunohost firewall disallow TCP $port +fi + #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete "$app" +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..10c5513 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,141 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ynh_clean_check_starting +} +# 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) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=2 + +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=60 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# 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 + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R "$app":"$app" "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=7 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --weight=6 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= + +yunohost service add $app --description "collaborative Markdown editor" --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" + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=5 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading Nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..621ab2b --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,216 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=2 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) + +db_name=$(ynh_app_setting_get --app=$app --key=app) +db_user=$(ynh_app_setting_get --app=$app --key=app) +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If db_name doesn't exist, create it +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + + mkdir -p $final_path + + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=120 + +# 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 + +#================================================= +# 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=160 + + +# Create a temporary directory +tmpdir="$(mktemp -d)" + +# Backup the config file in the temp dir +cp -a "$final_path/config.json" "$tmpdir/config.json" +cp -a "$final_path/.sequelizerc" "$tmpdir/.sequelizerc" + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" + +#Copy the admin saved settings from tmp directory to final path +cp -a "$tmpdir/config.json" "$final_path/config.json" +cp -a "$tmpdir/.sequelizerc" "$final_path/.sequelizerc" + +# Remove the tmp directory securely +ynh_secure_remove --file="$tmpdir" + +fi + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading Nginx web server configuration..." --weight=2 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=18 + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +ynh_install_app_dependencies $pkg_dependencies + +#============================================== +# INSTALL CODIMD +#============================================== +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Building application... (this will take some time and resources!)" --weight=160 + + pushd "$final_path" + + yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build + + popd +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 + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=2 + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" + +ynh_add_systemd_config + +#yunohost service add "$app" --description "CodiMD daemon" + +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R "$app":"$app" "$final_path" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2 + +# Make app public if necessary or protect it +[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" + +#================================================= +# 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" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file From 6edee22663f6ebd3bafe59074bc470d21dafa3f1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 13:02:26 +0200 Subject: [PATCH 04/67] various fix --- conf/app.src | 2 +- conf/systemd.service | 2 ++ scripts/install | 6 +++--- scripts/upgrade | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/conf/app.src b/conf/app.src index 10abb29..bb9317d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=3639eaf70a37ee0513c75259c70b3d0c2c10116e9b2989dc9c571f98017120bd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=codimd.tar.gz \ No newline at end of file +SOURCE_FILENAME=codimd.tar.gz diff --git a/conf/systemd.service b/conf/systemd.service index 7b1b7e5..5505b7d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,6 +5,8 @@ After=mysql.service [Service] Type=simple +User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" diff --git a/scripts/install b/scripts/install index 6b2a705..d9221e5 100644 --- a/scripts/install +++ b/scripts/install @@ -155,10 +155,10 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config diff --git a/scripts/upgrade b/scripts/upgrade index 621ab2b..d6a4712 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,14 +171,14 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config -#yunohost service add "$app" --description "CodiMD daemon" +yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" #================================================= # SECURE FILES AND DIRECTORIES From 15a245ff38f75fa2c03ea8552374919f2a29a661 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 13:44:50 +0200 Subject: [PATCH 05/67] Revert "various fix" This reverts commit 6edee22663f6ebd3bafe59074bc470d21dafa3f1. --- conf/app.src | 2 +- conf/systemd.service | 2 -- scripts/install | 6 +++--- scripts/upgrade | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/conf/app.src b/conf/app.src index bb9317d..10abb29 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=3639eaf70a37ee0513c75259c70b3d0c2c10116e9b2989dc9c571f98017120bd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=codimd.tar.gz +SOURCE_FILENAME=codimd.tar.gz \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index 5505b7d..7b1b7e5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,8 +5,6 @@ After=mysql.service [Service] Type=simple -User=__APP__ -Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" diff --git a/scripts/install b/scripts/install index d9221e5..6b2a705 100644 --- a/scripts/install +++ b/scripts/install @@ -155,10 +155,10 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config diff --git a/scripts/upgrade b/scripts/upgrade index d6a4712..621ab2b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,14 +171,14 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config -yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" +#yunohost service add "$app" --description "CodiMD daemon" #================================================= # SECURE FILES AND DIRECTORIES From 72436eb6884126528be1c0aebcb669051c39c56c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 14:24:25 +0200 Subject: [PATCH 06/67] remove Github Auth --- conf/config.json.example | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/conf/config.json.example b/conf/config.json.example index 3961f8d..52a4cd3 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -29,10 +29,6 @@ "host": "localhost", "port": "3306", "dialect": "mysql" - }, -# "github": { -# "clientID": "YOUR_clientID", -# "clientSecret": "YOUR_clientSecret" -# } + } } } \ No newline at end of file From 50f7a5c2f634fe39883c53f4d343a13b6a76d288 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 14:24:41 +0200 Subject: [PATCH 07/67] service add --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 621ab2b..bfe096d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -#yunohost service add "$app" --description "CodiMD daemon" +yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" #================================================= # SECURE FILES AND DIRECTORIES From 108563220381bc6ee0e60db0f87c55313f1f9228 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 14:24:59 +0200 Subject: [PATCH 08/67] rename service --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 7b1b7e5..f6d6867 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=__APP__ daemon +Description=Collaborative Markdown notes After=network.target After=mysql.service From 795d72f2d7ed997016b62024b93fe2aff55d280f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 14:25:18 +0200 Subject: [PATCH 09/67] minors fixs --- conf/app.src | 2 +- scripts/change_url | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 10abb29..bb9317d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=3639eaf70a37ee0513c75259c70b3d0c2c10116e9b2989dc9c571f98017120bd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=codimd.tar.gz \ No newline at end of file +SOURCE_FILENAME=codimd.tar.gz diff --git a/scripts/change_url b/scripts/change_url index 9702a07..fb272a3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= From 7cfaf8b4e57cf8cc38b8639d85907aee8a744a4a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 15:42:43 +0200 Subject: [PATCH 10/67] service description --- conf/systemd.service | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index f6d6867..d7bec22 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Collaborative Markdown notes +Description=__APP__: collaborative Markdown notes After=network.target After=mysql.service diff --git a/scripts/install b/scripts/install index 6b2a705..050bd6a 100644 --- a/scripts/install +++ b/scripts/install @@ -162,7 +162,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index bfe096d..b45c092 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "CodiMD daemon" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # SECURE FILES AND DIRECTORIES From 4a827776fb7af9759119fa02f75485f450765565 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 15:52:08 +0200 Subject: [PATCH 11/67] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b11d2b8..37d25be 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh1", + "version": "1.6.0~ynh2", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { From 919fa615f3dc073beb70d222f5f8d671e7d7098e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 16:14:14 +0200 Subject: [PATCH 12/67] add checksum --- scripts/install | 3 ++- scripts/upgrade | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 050bd6a..5aa5a7b 100644 --- a/scripts/install +++ b/scripts/install @@ -111,13 +111,14 @@ ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path"/config.json -ynh_store_file_checksum "$final_path/config.json" +ynh_store_file_checksum --file="$final_path/config.json" # DB Config File ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc +ynh_store_file_checksum --file="$final_path/.sequelizerc" #============================================== # INSTALL CODIMD diff --git a/scripts/upgrade b/scripts/upgrade index b45c092..f33f32a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,8 +156,46 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app + + + + #================================================= # SPECIFIC UPGRADE +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different --file="$final_path/config.json" +ynh_backup_if_checksum_is_different --file="$final_path/.sequelizerc" + + +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +cp ../conf/config.json.example "$final_path"/config.json +ynh_store_file_checksum "$final_path/config.json" + +# DB Config File +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" +cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/config.json" +ynh_store_file_checksum --file="$final_path/.sequelizerc" + + + + + #================================================= # SETUP LOGROTATE #================================================= From bdfce89432dd19608440883cb19b5ccae00d5856 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 16:25:04 +0200 Subject: [PATCH 13/67] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 37d25be..305575e 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh2", + "version": "1.6.0~ynh3", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { From 3b31755c4bc1b12c4e29b5749fe4059fe2c58d58 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 16:33:48 +0200 Subject: [PATCH 14/67] Revert "add checksum" This reverts commit 919fa615f3dc073beb70d222f5f8d671e7d7098e. --- scripts/install | 3 +-- scripts/upgrade | 38 -------------------------------------- 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/scripts/install b/scripts/install index 5aa5a7b..050bd6a 100644 --- a/scripts/install +++ b/scripts/install @@ -111,14 +111,13 @@ ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path"/config.json -ynh_store_file_checksum --file="$final_path/config.json" +ynh_store_file_checksum "$final_path/config.json" # DB Config File ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc -ynh_store_file_checksum --file="$final_path/.sequelizerc" #============================================== # INSTALL CODIMD diff --git a/scripts/upgrade b/scripts/upgrade index f33f32a..b45c092 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,46 +156,8 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app - - - - #================================================= # SPECIFIC UPGRADE -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/config.json" -ynh_backup_if_checksum_is_different --file="$final_path/.sequelizerc" - - -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -cp ../conf/config.json.example "$final_path"/config.json -ynh_store_file_checksum "$final_path/config.json" - -# DB Config File -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" -cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config.json" -ynh_store_file_checksum --file="$final_path/.sequelizerc" - - - - - #================================================= # SETUP LOGROTATE #================================================= From 5318eac048bccb2368d0be72990807b07b956b1a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 16:42:56 +0200 Subject: [PATCH 15/67] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 305575e..37d25be 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh3", + "version": "1.6.0~ynh2", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { From c0aeb6c61265b360838becce1ebc5677af8aa656 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 18:31:05 +0200 Subject: [PATCH 16/67] remove closing port --- scripts/remove | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/remove b/scripts/remove index 1c13051..f00aabe 100644 --- a/scripts/remove +++ b/scripts/remove @@ -77,16 +77,6 @@ ynh_remove_logrotate #================================================= # GENERIC FINALIZATION -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # REMOVE DEDICATED USER #================================================= From 7ced7bcd2e71ea90d46fc7996ab372959adc3d69 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 19:06:18 +0200 Subject: [PATCH 17/67] remove Downward compatibility --- scripts/upgrade | 54 +++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b45c092..440d42f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,35 +32,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - - mkdir -p $final_path - - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -91,26 +62,25 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=160 - -# Create a temporary directory -tmpdir="$(mktemp -d)" + # Create a temporary directory + tmpdir="$(mktemp -d)" -# Backup the config file in the temp dir -cp -a "$final_path/config.json" "$tmpdir/config.json" -cp -a "$final_path/.sequelizerc" "$tmpdir/.sequelizerc" + # Backup the config file in the temp dir + cp -a "$final_path/config.json" "$tmpdir/config.json" + cp -a "$final_path/.sequelizerc" "$tmpdir/.sequelizerc" -# Remove the app directory securely -ynh_secure_remove --file="$final_path" + # Remove the app directory securely + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -#Copy the admin saved settings from tmp directory to final path -cp -a "$tmpdir/config.json" "$final_path/config.json" -cp -a "$tmpdir/.sequelizerc" "$final_path/.sequelizerc" + #Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/config.json" "$final_path/config.json" + cp -a "$tmpdir/.sequelizerc" "$final_path/.sequelizerc" -# Remove the tmp directory securely -ynh_secure_remove --file="$tmpdir" + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi From e274a9e31b1ca601e33d7d458e5c4e47a0916399 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 21 May 2020 19:08:38 +0200 Subject: [PATCH 18/67] remove script_progression --- scripts/backup | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 9a1989f..5dff667 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -22,42 +21,38 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_print_info --message="Loading installation 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) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$(ynh_app_setting_get --app=$app --key=db_user) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --weight=1 ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up Nginx web server configuration..." --weight=1 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the MySQL database..." --weight=1 +ynh_print_info --message="Backing up the database..." ynh_mysql_dump_db --database="$db_name" > db.sql @@ -66,21 +61,18 @@ ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --weight=2 ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --weight=1 ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # 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" @@ -88,4 +80,4 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" - # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." From 3bb697888bc26cea0309c512aaf434890767c1aa Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 09:10:20 +0200 Subject: [PATCH 19/67] move to postgres --- conf/.sequelizerc.example | 2 +- conf/config.json.example | 6 +++--- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/install | 4 +++- scripts/remove | 6 +++--- scripts/restore | 10 +++++----- scripts/upgrade | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 29b59f2..45ef120 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -4,5 +4,5 @@ module.exports = { 'config': path.resolve('config.json'), 'migrations-path': path.resolve('lib', 'migrations'), 'models-path': path.resolve('lib', 'models'), - 'url': 'mysql://__DB_USER__:__DB_PASS__@localhost:3306/__DB_NAME__' + 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' } diff --git a/conf/config.json.example b/conf/config.json.example index 52a4cd3..a6dc5a0 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -27,8 +27,8 @@ "password": "__DB_PASS__", "database": "__DB_NAME__", "host": "localhost", - "port": "3306", - "dialect": "mysql" + "port": "5432", + "dialect": "postgres" } } -} \ No newline at end of file +} diff --git a/scripts/_common.sh b/scripts/_common.sh index 53e412e..b113120 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="apt-transport-https" +pkg_dependencies="postgresql apt-transport-https" nodejs_version="10" diff --git a/scripts/backup b/scripts/backup index 5dff667..1033992 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,11 +50,11 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE DATABASE #================================================= ynh_print_info --message="Backing up the database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 050bd6a..83fdb4d 100644 --- a/scripts/install +++ b/scripts/install @@ -80,8 +80,10 @@ ynh_script_progression --message="Creating a database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name + +ynh_psql_test_if_first_run ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" -ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index f00aabe..512eea8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,12 +34,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=2 +ynh_script_progression --message="Removing the database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 10c5513..caf90d2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,13 +89,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=6 +ynh_script_progression --message="Restoring the database..." --weight=6 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 440d42f..b275458 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=app) db_user=$(ynh_app_setting_get --app=$app --key=app) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlwd) #================================================= # CHECK VERSION From 9a4fc883499433e68033608efbde625bf5ab58b9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 10:35:03 +0200 Subject: [PATCH 20/67] add pull request template --- pull_request_template.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pull_request_template.md diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..b16fe61 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/codimd_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/codimd_ynh%20PR-NUM-%20(USERNAME)/) From e28c9f2a7d85412418e4283f167d404bf8337474 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 10:35:30 +0200 Subject: [PATCH 21/67] update README --- README.md | 2 +- README_fr.md | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e307507..e022b05 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Collaborative editor to work on notes written in Markdown. ## Configuration -If you need to configure CodiMD, you can tweak /var/www/codimd/config.json file using this [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) +If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` file using this [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) ## Documentation diff --git a/README_fr.md b/README_fr.md index 593a25a..d054592 100644 --- a/README_fr.md +++ b/README_fr.md @@ -23,9 +23,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Configuration -Français - -Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier /var/www/codimd/config.json en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) +Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/codimd/config.json` en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) ## Documentation From af485497154908907230614775cf3ac88517df46 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 10:40:49 +0200 Subject: [PATCH 22/67] Revert "move to postgres" This reverts commit 3bb697888bc26cea0309c512aaf434890767c1aa. --- conf/.sequelizerc.example | 2 +- conf/config.json.example | 6 +++--- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/install | 4 +--- scripts/remove | 6 +++--- scripts/restore | 10 +++++----- scripts/upgrade | 2 +- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 45ef120..29b59f2 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -4,5 +4,5 @@ module.exports = { 'config': path.resolve('config.json'), 'migrations-path': path.resolve('lib', 'migrations'), 'models-path': path.resolve('lib', 'models'), - 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' + 'url': 'mysql://__DB_USER__:__DB_PASS__@localhost:3306/__DB_NAME__' } diff --git a/conf/config.json.example b/conf/config.json.example index a6dc5a0..52a4cd3 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -27,8 +27,8 @@ "password": "__DB_PASS__", "database": "__DB_NAME__", "host": "localhost", - "port": "5432", - "dialect": "postgres" + "port": "3306", + "dialect": "mysql" } } -} +} \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index b113120..53e412e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql apt-transport-https" +pkg_dependencies="apt-transport-https" nodejs_version="10" diff --git a/scripts/backup b/scripts/backup index 1033992..5dff667 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,11 +50,11 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE DATABASE +# BACKUP THE MYSQL DATABASE #================================================= ynh_print_info --message="Backing up the database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 83fdb4d..050bd6a 100644 --- a/scripts/install +++ b/scripts/install @@ -80,10 +80,8 @@ ynh_script_progression --message="Creating a database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name - -ynh_psql_test_if_first_run ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" +ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index 512eea8..f00aabe 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,12 +34,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE DATABASE +# REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the database..." --weight=2 +ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index caf90d2..10c5513 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,13 +89,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= -# RESTORE THE DATABASE +# RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the database..." --weight=6 +ynh_script_progression --message="Restoring the MySQL database..." --weight=6 -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index b275458..440d42f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=app) db_user=$(ynh_app_setting_get --app=$app --key=app) -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= # CHECK VERSION From b32e082487392c7977341cf690152b67e2c24c1f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 18:59:38 +0200 Subject: [PATCH 23/67] add remove service integration --- scripts/remove | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/remove b/scripts/remove index f00aabe..29ed05f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,6 +25,17 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= + +# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null +then + ynh_script_progression --message="Removing $app service..." --weight=1 + yunohost service remove $app +fi + #================================================= # STOP AND REMOVE SERVICE #================================================= From 28d6e0d5cdfb3d5a4491c961cb1ccd43c789819d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 09:14:00 +0200 Subject: [PATCH 24/67] move to postesql --- conf/.sequelizerc.example | 2 +- conf/config.json.example | 4 ++-- conf/systemd.service | 2 +- manifest.json | 3 +-- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/change_url | 6 +++--- scripts/install | 12 +++++++++--- scripts/remove | 11 +++++------ scripts/restore | 13 +++++++------ scripts/upgrade | 10 +++------- 11 files changed, 35 insertions(+), 34 deletions(-) diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 29b59f2..45ef120 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -4,5 +4,5 @@ module.exports = { 'config': path.resolve('config.json'), 'migrations-path': path.resolve('lib', 'migrations'), 'models-path': path.resolve('lib', 'models'), - 'url': 'mysql://__DB_USER__:__DB_PASS__@localhost:3306/__DB_NAME__' + 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' } diff --git a/conf/config.json.example b/conf/config.json.example index 52a4cd3..28b8bdf 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -27,8 +27,8 @@ "password": "__DB_PASS__", "database": "__DB_NAME__", "host": "localhost", - "port": "3306", - "dialect": "mysql" + "port": "5432", + "dialect": "postgres" } } } \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index d7bec22..c7b91d0 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=__APP__: collaborative Markdown notes After=network.target -After=mysql.service +After=postgresql.service [Service] Type=simple diff --git a/manifest.json b/manifest.json index 37d25be..ddd9f95 100644 --- a/manifest.json +++ b/manifest.json @@ -17,8 +17,7 @@ }, "multi_instance": true, "services": [ - "nginx", - "mysql" + "nginx" ], "arguments": { "install": [{ diff --git a/scripts/_common.sh b/scripts/_common.sh index 53e412e..b113120 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="apt-transport-https" +pkg_dependencies="postgresql apt-transport-https" nodejs_version="10" diff --git a/scripts/backup b/scripts/backup index 5dff667..1033992 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,11 +50,11 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE DATABASE #================================================= ynh_print_info --message="Backing up the database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/change_url b/scripts/change_url index fb272a3..5919876 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +db_user=$(ynh_app_setting_get --app=$app --key=db_user) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= @@ -74,7 +74,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -112,7 +112,7 @@ fi #================================================= 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" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 050bd6a..4862ca2 100644 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path -ynh_webpath_register "$app" "$domain" $path_url +ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" #================================================= # FIND AND OPEN A PORT @@ -68,7 +68,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_install_app_dependencies $pkg_dependencies # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -80,8 +80,14 @@ ynh_script_progression --message="Creating a database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name +db_pwd=$(ynh_string_random --length=30) + +ynh_app_setting_set --app="$app" --key="db_pwd" --value="$db_pwd" ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" -ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" +ynh_app_setting_set --app="$app" --key="db_user" --value="$db_user" + +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index 29ed05f..6a47a30 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,11 +18,10 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$(ynh_app_setting_get --app=$app --key=db_user) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # STANDARD REMOVE #================================================= @@ -45,12 +44,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=2 +ynh_script_progression --message="Removing the database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES @@ -94,7 +93,7 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 10c5513..6cbfb2a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -64,7 +65,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username="$app" #================================================= # RESTORE USER RIGHTS @@ -89,13 +90,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=6 +ynh_script_progression --message="Restoring the database..." --weight=6 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 440d42f..24617da 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,10 +22,6 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=app) -db_user=$(ynh_app_setting_get --app=$app --key=app) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - #================================================= # CHECK VERSION #================================================= @@ -124,7 +120,7 @@ fi 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 +ynh_system_user_create --username="$app" #================================================= # SPECIFIC UPGRADE @@ -170,7 +166,7 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2 #================================================= 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" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # RELOAD NGINX @@ -183,4 +179,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" --last From 3edadf6c0d10806801f2167e3cd5716dc61a9eaa Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 10:24:36 +0200 Subject: [PATCH 25/67] Remove helpers that are now part of 3.8 --- scripts/_common.sh | 244 --------------------------------------------- 1 file changed, 244 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b113120..fad338c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,247 +8,3 @@ pkg_dependencies="postgresql apt-transport-https" nodejs_version="10" - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#!/bin/bash - -# Pin a repository. -# -# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] -# | arg: -p, --package - Packages concerned by the pin. Or all, *. -# | arg: -i, --pin - Filter for the pin. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. -# -ynh_pin_repo () { - # Declare an array to define the options of this helper. - local legacy_args=pirna - declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) - local package - local pin - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package="${package:-*}" - priority=${priority:-50} - name="${name:-$app}" - append=${append:-0} - - if [ "$append" -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/preferences.d" - echo "Package: $package - Pin: $pin - Pin-Priority: $priority" \ - | $append "/etc/apt/preferences.d/$name" -} - -# Add a repository. -# -# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] -# | arg: -u, --uri - Uri of the repository. -# | arg: -s, --suite - Suite of the repository. -# | arg: -c, --component - Component of the repository. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable -# uri suite component -# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable -# -ynh_add_repo () { - # Declare an array to define the options of this helper. - local legacy_args=uscna - declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) - local uri - local suite - local component - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/sources.list.d" - # Add the new repo in sources.list.d - echo "deb $uri $suite $component" \ - | $append "/etc/apt/sources.list.d/$name.list" -} - -# Add an extra repository correctly, pin it and get the key. -# -# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -k, --key - url to get the public key. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -ynh_install_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=rkpna - declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) - local repo - local key - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - key=${key:-0} - priority=${priority:-} - - if [ $append -eq 1 ] - then - append="--append" - wget_append="tee -a" - else - append="" - wget_append="tee" - fi - - # Split the repository into uri, suite and components. - # Remove "deb " at the beginning of the repo. - repo="${repo#deb }" - - # Get the uri - local uri="$(echo "$repo" | awk '{ print $1 }')" - - # Get the suite - local suite="$(echo "$repo" | awk '{ print $2 }')" - - # Get the components - local component="${repo##$uri $suite }" - - # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append - - # Pin the new repo with the default priority, so it won't be used for upgrades. - # Build $pin from the uri without http and any sub path - local pin="${uri#*://}" - pin="${pin%%/*}" - # Set a priority only if asked - if [ -n "$priority" ] - then - priority="--priority=$priority" - fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" "$priority" --name="$name" $append - - # Get the public key for the repo - if [ -n "$key" ] - then - mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/"$name".gpg > /dev/null - fi - - # Update the list of package with the new repo - ynh_package_update -} - -# Remove an extra repository and the assiociated configuration. -# -# usage: ynh_remove_extra_repo [--name=name] -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_remove_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=n - declare -Ar args_array=( [n]=name= ) - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - - ynh_secure_remove "/etc/apt/sources.list.d/$name.list" - ynh_secure_remove "/etc/apt/preferences.d/$name" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" - - # Update the list of package to exclude the old repo - ynh_package_update -} - -# Install packages from an extra repository properly. -# -# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -p, --package - The packages to install from this extra repository -# | arg: -k, --key - url to get the public key. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_install_extra_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=rpkn - declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) - local repo - local package - local key - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - key=${key:-0} - - # Set a key only if asked - if [ -n "$key" ] - then - key="--key=$key" - fi - # Add an extra repository for those packages - ynh_install_extra_repo --repo="$repo" "$key" --priority=995 --name="$name" - - # Install requested dependencies from this extra repository. - ynh_add_app_dependencies --package="$package" - - # Remove this extra repository after packages are installed - ynh_remove_extra_repo --name="$app" -} - -ynh_add_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=pr - declare -Ar args_array=( [p]=package= [r]=replace) - local package - local replace - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - replace=${replace:-0} - - local current_dependencies="" - if [ "$replace" -eq 0 ] - then - local dep_app=${app//_/-} # Replace all '_' by '-' - if ynh_package_is_installed --package="${dep_app}-ynh-deps" - then - current_dependencies="$(dpkg-query --show --showformat='${Depends}' "${dep_app}"-ynh-deps) " - fi - - current_dependencies=${current_dependencies// | /|} - fi - - ynh_install_app_dependencies "${current_dependencies}${package}" -} From 7ce7df319d123a086445ed15f7e06c79bf1ba3c3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 10:24:55 +0200 Subject: [PATCH 26/67] requirements set to 3.8 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ddd9f95..b3545ab 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "liberodark" }, "requirements": { - "yunohost": ">= 3.7.0" + "yunohost": ">= 3.8.0" }, "multi_instance": true, "services": [ From f419c72899cfce79c81a4e343dad6a58df0ef988 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 13:27:29 +0200 Subject: [PATCH 27/67] ynh_install_extra_app_dependencies implies requiring at least version 3.8.1 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b3545ab..ef9272a 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "liberodark" }, "requirements": { - "yunohost": ">= 3.8.0" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ From c5d1f7f793673d23a08cee80683cfeb11ec65199 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 15:12:44 +0200 Subject: [PATCH 28/67] add doc link --- README.md | 2 +- README_fr.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e022b05..de28dd2 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` fil ## Documentation * Official documentation: https://hackmd.io/c/codimd-documentation/ - * YunoHost documentation: If specific documentation is needed, feel free to contribute. + * YunoHost documentation: https://yunohost.org/#/app_codimd ## YunoHost specific features diff --git a/README_fr.md b/README_fr.md index d054592..095b96c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,7 +6,7 @@ *[Read this readme in english.](./README.md)* > *Ce package vous permet d’installer CodiMD 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.* +Si vous n’avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l’installer.* ## Vue d’ensemble Éditeur collaboratif pour travailler sur des notes en Markdown. @@ -28,7 +28,7 @@ Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/c ## Documentation * Documentation officielle : https://hackmd.io/c/codimd-documentation/ - * Documentation YunoHost : Si une documentation spécifique est nécessaire, n’hésitez pas à contribuer. + * Documentation YunoHost : https://yunohost.org/#/app_codimd_fr ## Caractéristiques spécifiques YunoHost From 1e9ebe1d4860c3d0184dac4b0cdb78f44dbc5f57 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 15:16:02 +0200 Subject: [PATCH 29/67] Create check_process --- check_process | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 check_process diff --git a/check_process b/check_process new file mode 100644 index 0000000..cd20538 --- /dev/null +++ b/check_process @@ -0,0 +1,22 @@ +;; Test complet + ; Manifest + domain="domain.tld" (DOMAIN) + admin="john" (USER) + is_public=1 (PUBLIC|public=1|private=0) + ; 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 + port_already_use=0 + change_url=1 +;;; Levels + Level 5=auto +;;; Options +Email= +Notification=none \ No newline at end of file From 2959b9762dcdb14ecf7482b1ad6aa206e7ab52cb Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 15:16:11 +0200 Subject: [PATCH 30/67] Update systemd.service --- conf/systemd.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index c7b91d0..6797ec1 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,6 +5,8 @@ After=postgresql.service [Service] Type=simple +User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" From e19989fd6013d2019db9396f4e906f103cbbdb64 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 23:40:14 +0200 Subject: [PATCH 31/67] fix permission --- scripts/upgrade | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 24617da..6736bb0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -153,14 +153,6 @@ yunohost service add "$app" --description "Collaborative Markdown notes" --log=" # Set permissions on app files chown -R "$app":"$app" "$final_path" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2 - -# Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" - #================================================= # START SYSTEMD SERVICE #================================================= From d151302c1344e1c41059896865525abb5fd96157 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 23:41:19 +0200 Subject: [PATCH 32/67] set version to 1.6.0~ynh1 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ef9272a..2999b99 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh2", + "version": "1.6.0~ynh1", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { From 6b204fd7fd186bb37374da0aec5122f7af5c8f1d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 May 2020 23:41:26 +0200 Subject: [PATCH 33/67] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index cd20538..a4b4332 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Levels Level 5=auto ;;; Options From e442fbb812c82c57913603370e59ee204b13295c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 24 May 2020 10:50:26 +0200 Subject: [PATCH 34/67] more explicit info --- scripts/change_url | 6 +++--- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/upgrade | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 5919876..61a48cb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,7 +37,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1 +ynh_script_progression --message="Backing up $app before changing its url (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -79,7 +79,7 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$a #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 +ynh_script_progression --message="Updating Nginx web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -117,7 +117,7 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading Nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 4862ca2..719407f 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=2 +ynh_script_progression --message="Configuring Nginx web server..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -128,7 +128,7 @@ cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc #============================================== # INSTALL CODIMD #============================================== -ynh_script_progression --message="Building application... (this will take some time and resources!)" --weight=240 +ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=240 pushd "$final_path" || ynh_die diff --git a/scripts/remove b/scripts/remove index 6a47a30..8d9ff85 100644 --- a/scripts/remove +++ b/scripts/remove @@ -64,7 +64,7 @@ ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=6 +ynh_script_progression --message="Removing $app main directory..." --weight=6 # Remove the app directory securely ynh_secure_remove --file="$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 6736bb0..1787967 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,7 +31,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=120 +ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=120 # Backup the current version of the app ynh_backup_before_upgrade @@ -105,7 +105,7 @@ ynh_install_app_dependencies $pkg_dependencies #============================================== if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Building application... (this will take some time and resources!)" --weight=160 + ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=160 pushd "$final_path" @@ -163,7 +163,7 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading Nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload From 1842d5b0343ab3c30efb2c8a9d23f0b6dd0ff3ea Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 24 May 2020 20:32:52 +0200 Subject: [PATCH 35/67] set port to 3000 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 719407f..e1ef0e3 100644 --- a/scripts/install +++ b/scripts/install @@ -47,7 +47,7 @@ ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" ynh_script_progression --message="Configuring firewall..." --weight=2 # Find an available port -port=$(ynh_find_port --port=3002) +port=$(ynh_find_port --port=3000) ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= From d3cbffb86c88c8706c6c9e51f103421aa891a103 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 24 May 2020 22:50:23 +0200 Subject: [PATCH 36/67] checksum if the config has been modified --- scripts/install | 7 +++++-- scripts/upgrade | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index e1ef0e3..144104d 100644 --- a/scripts/install +++ b/scripts/install @@ -116,14 +116,17 @@ ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1 ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -cp ../conf/config.json.example "$final_path"/config.json + +cp ../conf/config.json.example "$final_path/config.json" + ynh_store_file_checksum "$final_path/config.json" # DB Config File ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" -cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc + +cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" #============================================== # INSTALL CODIMD diff --git a/scripts/upgrade b/scripts/upgrade index 1787967..5861b01 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,6 +80,28 @@ then fi +#================================================= +# SPECIFIC UPGRADE +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." --weight=2 + +ynh_backup_if_checksum_is_different --file="$final_path/config.json" + +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" + +cp ../conf/config.json.example "$final_path/config.json" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/config.json" + #================================================= # NGINX CONFIGURATION #================================================= @@ -96,7 +118,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=18 # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_install_app_dependencies $pkg_dependencies From fcffcc4ab9733823b43b369c9567717591a1ff55 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 24 May 2020 23:06:38 +0200 Subject: [PATCH 37/67] add DB variables --- scripts/install | 2 +- scripts/upgrade | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 144104d..708c6ba 100644 --- a/scripts/install +++ b/scripts/install @@ -191,7 +191,7 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1 #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading Nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 5861b01..b762fa7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,11 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +# Add settings here as needed by your application +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + #================================================= # CHECK VERSION #================================================= From 17d2075cd6fa3e3744290a7c3ebae7063221a420 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 25 May 2020 14:13:00 +0200 Subject: [PATCH 38/67] cleaning up --- README.md | 2 -- README_fr.md | 2 -- conf/config.json.example | 2 +- scripts/install | 2 +- scripts/upgrade | 1 - 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index de28dd2..cb65e72 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,6 @@ If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` fil ## Limitations -**Status**: In progress, do *not* consider this app as stable and fully working (yet) - ## Additional information ## Links diff --git a/README_fr.md b/README_fr.md index 095b96c..900b4e5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -44,8 +44,6 @@ Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/c ## Limitations -**Statut** : En cours, ne *pas encore* considérer cette application comme stable et fonctionnant. - ## Informations additionnelles ## Liens diff --git a/conf/config.json.example b/conf/config.json.example index 28b8bdf..444d992 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -2,7 +2,7 @@ "production": { "protocolUseSSL": true, "domain": "__DOMAIN__", - "port": __PORT__, + "port": "__PORT__", "loglevel": "info", "useCDN": false, "allowGravatar": false, diff --git a/scripts/install b/scripts/install index 708c6ba..f359e64 100644 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,7 @@ ynh_script_progression --message="Configuring firewall..." --weight=2 # Find an available port port=$(ynh_find_port --port=3000) -ynh_app_setting_set --app="$app" --key="port" --value="$port" +ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= # STORE SETTINGS FROM MANIFEST diff --git a/scripts/upgrade b/scripts/upgrade index b762fa7..0ad1ad0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,6 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) -# Add settings here as needed by your application db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$(ynh_app_setting_get --app=$app --key=db_user) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) From 5e53c9f4709c1094d1968a87a5cd7e480d58794e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 25 May 2020 18:46:30 +0200 Subject: [PATCH 39/67] remove stop/start systemd service --- scripts/backup | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 1033992..6fad76a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -31,12 +31,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -# STOP SYSTEMD SERVICE -#================================================= - -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -70,12 +64,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# START SYSTEMD SERVICE -#================================================= - -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="HTTP Server listening" - #================================================= # END OF SCRIPT #================================================= From 678c32d9076c504e578e194943f87a4e36c13050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 25 May 2020 19:08:15 +0200 Subject: [PATCH 40/67] Update manifest.json Co-authored-by: Alexandre Aubin --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 2999b99..aba7943 100644 --- a/manifest.json +++ b/manifest.json @@ -27,7 +27,7 @@ "en": "Choose a domain name for CodiMD", "fr": "Choisissez un nom de domaine pour CodiMD" }, - "example": "codimd.domaim.org" + "example": "codimd.domain.org" }, { "name": "is_public", From 6ba52b7a61fffb0fce2ac7cf71f0647eda012e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 25 May 2020 19:08:32 +0200 Subject: [PATCH 41/67] Update manifest.json Co-authored-by: Alexandre Aubin --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index aba7943..53bf27e 100644 --- a/manifest.json +++ b/manifest.json @@ -37,7 +37,7 @@ "fr": "Est-ce un site public ?" }, "help": { - "en": "If enabled, CodiMD will be accessible by people who doesn’t have an account. This can be changed later via the webadmin.", + "en": "If enabled, CodiMD 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, CodiMD sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." }, "default": true From 3f57c9e7782fe60d18df042e108e7424d528410d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 23:41:23 +0200 Subject: [PATCH 42/67] Update config.json.example --- conf/config.json.example | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conf/config.json.example b/conf/config.json.example index 444d992..ed62172 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -29,6 +29,14 @@ "host": "localhost", "port": "5432", "dialect": "postgres" + }, + "ldap": { + "url": "ldap://127.0.0.1", + "bindDn": "ou=users,dc=yunohost,dc=org", + "bindCredentials": "", + "searchBase": "dc=internal,dc=example,dc=com", + "searchFilter": "(&(objectcategory=person)(objectclass=user)(|(sAMAccountName={{username}})(mail={{username}})))", + "useridField": "uid" } } } \ No newline at end of file From 318977ab737bdc03b0c9adb21d767beeabcfece0 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 08:34:50 +0200 Subject: [PATCH 43/67] subfolder --- conf/config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index ed62172..4122137 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -31,7 +31,7 @@ "dialect": "postgres" }, "ldap": { - "url": "ldap://127.0.0.1", + "url": "ldap://127.0.0.1:389", "bindDn": "ou=users,dc=yunohost,dc=org", "bindCredentials": "", "searchBase": "dc=internal,dc=example,dc=com", From 1281583d6ee6d3997884a5dfcaa379218168b777 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 17:54:27 +0200 Subject: [PATCH 44/67] Update config.json.example --- conf/config.json.example | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/conf/config.json.example b/conf/config.json.example index 4122137..9a2032c 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -32,11 +32,15 @@ }, "ldap": { "url": "ldap://127.0.0.1:389", - "bindDn": "ou=users,dc=yunohost,dc=org", - "bindCredentials": "", - "searchBase": "dc=internal,dc=example,dc=com", - "searchFilter": "(&(objectcategory=person)(objectclass=user)(|(sAMAccountName={{username}})(mail={{username}})))", + "bindDn": null, + "bindCredentials": null, + "searchBase": "ou=users,dc=yunohost,dc=org", + "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=codimd.main,ou=permission,dc=yunohost,dc=org))", + "usernameField": "cn", "useridField": "uid" - } + } } -} \ No newline at end of file +} + + + From b9a182cf6a80032f101911042a91e535080ee998 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 17:57:12 +0200 Subject: [PATCH 45/67] add __APP__ for ldap --- conf/config.json.example | 2 +- scripts/upgrade | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index 9a2032c..2eded54 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -35,7 +35,7 @@ "bindDn": null, "bindCredentials": null, "searchBase": "ou=users,dc=yunohost,dc=org", - "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=codimd.main,ou=permission,dc=yunohost,dc=org))", + "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))", "usernameField": "cn", "useridField": "uid" } diff --git a/scripts/upgrade b/scripts/upgrade index 0ad1ad0..60b685e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -100,6 +100,7 @@ ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1 ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path/config.json" From 038a9dd5352d22500d7d9fd23c32360c61d3fcac Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 18:00:00 +0200 Subject: [PATCH 46/67] Update config.json.example --- conf/config.json.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index 2eded54..c40d4a4 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -37,7 +37,8 @@ "searchBase": "ou=users,dc=yunohost,dc=org", "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))", "usernameField": "cn", - "useridField": "uid" + "useridField": "uid", + "providerName": "YunoHost" } } } From 93c358c0bcc0591e1096360865e2d0e964326866 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 19:02:56 +0200 Subject: [PATCH 47/67] Update install --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index f359e64..86fc3f0 100644 --- a/scripts/install +++ b/scripts/install @@ -55,6 +55,7 @@ ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 +ynh_app_setting_set --app="$app" --key="app" --value="$app" ynh_app_setting_set --app="$app" --key="domain" --value="$domain" ynh_app_setting_set --app="$app" --key="path" --value="$path_url" ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" @@ -116,6 +117,7 @@ ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1 ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path/config.json" From 3c80ea4924baf50768bb038c1ee5a13f0c34f9ac Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 19:15:50 +0200 Subject: [PATCH 48/67] Ldap support to yes --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb65e72..268587c 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` fil #### Multi-users support -* Is LDAP supported? No +* Is LDAP supported? Yes * Can the app be used by multiple users? Yes #### Supported architectures diff --git a/README_fr.md b/README_fr.md index 900b4e5..5c61c1b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/c #### Support multi-utilisateurs -* L’authentification LDAP est-elle prise en charge ? Non +* L’authentification LDAP est-elle prise en charge ? Oui * L’application peut-elle être utilisée par plusieurs utilisateurs ? Oui #### Architectures supportées From 5528f11d69495897d409f9cb8a3c54a82eb92fe4 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 20:17:01 +0200 Subject: [PATCH 49/67] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 53bf27e..d14112a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh1", + "version": "1.6.0~ynh3", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { From 9d661ef4856aeb90ad95ab5ea284992d486fb19c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 28 May 2020 20:24:45 +0200 Subject: [PATCH 50/67] Update install --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 86fc3f0..2897b1f 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,6 @@ ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app="$app" --key="app" --value="$app" ynh_app_setting_set --app="$app" --key="domain" --value="$domain" ynh_app_setting_set --app="$app" --key="path" --value="$path_url" ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" From ed8b97dc83c3ff03c889acc7391418e7688fd391 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 29 May 2020 12:27:15 +0200 Subject: [PATCH 51/67] Allow new note creation by accessing a nonexistent note URL --- conf/config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index c40d4a4..bd1435d 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -6,7 +6,7 @@ "loglevel": "info", "useCDN": false, "allowGravatar": false, - "allowPDFExport": false, + "allowFreeURL" true, "hsts": { "enable": true, "maxAgeSeconds": 31536000, From 04c53702d9a1d7dffac6e64a708e8b39a0c0212c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 29 May 2020 13:02:03 +0200 Subject: [PATCH 52/67] fix typo --- conf/config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index bd1435d..51f55c1 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -6,7 +6,7 @@ "loglevel": "info", "useCDN": false, "allowGravatar": false, - "allowFreeURL" true, + "allowFreeURL": true, "hsts": { "enable": true, "maxAgeSeconds": 31536000, From db39e807420628270763cf126929620b94ff3779 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 29 May 2020 22:31:43 +0200 Subject: [PATCH 53/67] cleaning up --- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/change_url | 4 ++-- scripts/install | 28 ++++++++++++++-------------- scripts/remove | 6 +++--- scripts/restore | 12 ++++++------ scripts/upgrade | 28 ++++++++++++++-------------- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/manifest.json b/manifest.json index d14112a..e6e1b74 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh3", + "version": "1.6.0~ynh2", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index fad338c..b0b3f5f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,4 +7,4 @@ # dependencies used by the app pkg_dependencies="postgresql apt-transport-https" -nodejs_version="10" +nodejs_version=10 diff --git a/scripts/backup b/scripts/backup index 6fad76a..b342a14 100644 --- a/scripts/backup +++ b/scripts/backup @@ -35,7 +35,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path=$final_path #================================================= # BACKUP THE NGINX CONFIGURATION @@ -48,7 +48,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info --message="Backing up the database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database=$db_name > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/change_url b/scripts/change_url index 61a48cb..5689c59 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -74,7 +74,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -112,7 +112,7 @@ fi #================================================= 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" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 2897b1f..c817b9d 100644 --- a/scripts/install +++ b/scripts/install @@ -48,17 +48,17 @@ ynh_script_progression --message="Configuring firewall..." --weight=2 # Find an available port port=$(ynh_find_port --port=3000) -ynh_app_setting_set --app="$app" --key="port" --value="$port" +ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # 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" -ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" -ynh_app_setting_set --app="$app" --key="final_path" --value="$final_path" +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=final_path --value=$final_path #============================================== # INSTALL DEPENDENCIES @@ -68,7 +68,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_install_app_dependencies $pkg_dependencies # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -82,12 +82,12 @@ db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app="$app" --key="db_pwd" --value="$db_pwd" -ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" -ynh_app_setting_set --app="$app" --key="db_user" --value="$db_user" +ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_app_setting_set --app=$app --key=db_user --value=$db_user ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -95,7 +95,7 @@ ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_script_progression --message="Setting up source files..." --weight=2 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir=$final_path #================================================= # NGINX CONFIGURATION @@ -148,7 +148,7 @@ popd || ynh_die ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user -ynh_system_user_create "$app" +ynh_system_user_create --username=$app --home_dir=$final_path chown -R "$app":"$app" "$final_path" @@ -172,14 +172,14 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" +yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app..." --weight=2 -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="HTTP Server listening" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 8d9ff85..0d524ee 100644 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing the database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES @@ -67,7 +67,7 @@ ynh_remove_nodejs ynh_script_progression --message="Removing $app main directory..." --weight=6 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +ynh_secure_remove --file=$final_path #================================================= # REMOVE NGINX CONFIGURATION @@ -93,7 +93,7 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username="$app" +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 6cbfb2a..8a2927d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -57,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=60 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path=$final_path #================================================= # RECREATE THE DEDICATED USER @@ -65,7 +65,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username="$app" +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -87,7 +87,7 @@ ynh_install_app_dependencies $pkg_dependencies # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # RESTORE THE DATABASE @@ -95,8 +95,8 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_script_progression --message="Restoring the database..." --weight=6 ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" -ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD @@ -117,7 +117,7 @@ yunohost service add $app --description "collaborative Markdown editor" --log "/ #================================================= 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" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 60b685e..25f830d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,7 +53,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -70,10 +70,10 @@ then cp -a "$final_path/.sequelizerc" "$tmpdir/.sequelizerc" # Remove the app directory securely - ynh_secure_remove --file="$final_path" + ynh_secure_remove --file=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir=$final_path #Copy the admin saved settings from tmp directory to final path cp -a "$tmpdir/config.json" "$final_path/config.json" @@ -94,13 +94,13 @@ ynh_script_progression --message="Modifying a config file..." --weight=2 ynh_backup_if_checksum_is_different --file="$final_path/config.json" # Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path/config.json" @@ -123,7 +123,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=18 # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_app_dependencies $pkg_dependencies @@ -147,7 +147,7 @@ fi 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" +ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE @@ -171,7 +171,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" +yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # SECURE FILES AND DIRECTORIES @@ -185,7 +185,7 @@ chown -R "$app":"$app" "$final_path" #================================================= 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" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" #================================================= # RELOAD NGINX From 021edce1339e129827dc9aca50b7081274773f2a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 29 May 2020 23:02:01 +0200 Subject: [PATCH 54/67] cleaning --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index c817b9d..f8206d2 100644 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path -ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # FIND AND OPEN A PORT @@ -150,7 +150,7 @@ ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path -chown -R "$app":"$app" "$final_path" +chown -R $app:$app $final_path #================================================= # SETUP LOGROTATE diff --git a/scripts/restore b/scripts/restore index 8a2927d..dc72ab7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,7 @@ ynh_system_user_create --username=$app #================================================= # Restore permissions on app files -chown -R "$app":"$app" "$final_path" +chown -R $app:$app $final_path #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 25f830d..120b041 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,7 @@ yunohost service add $app --description "Collaborative Markdown notes" --log="/v #================================================= # Set permissions on app files -chown -R "$app":"$app" "$final_path" +chown -R $app:$app $final_path #================================================= # START SYSTEMD SERVICE From 4d65d05d439537de3d43f3ec738e7323d61e2111 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 19:04:13 +0200 Subject: [PATCH 55/67] add ynh_use_nodejs --- scripts/install | 4 +++- scripts/upgrade | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f8206d2..d73b3a9 100644 --- a/scripts/install +++ b/scripts/install @@ -136,7 +136,9 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd "$final_path" || ynh_die -yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build + ynh_use_nodejs + + yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build popd || ynh_die diff --git a/scripts/upgrade b/scripts/upgrade index 120b041..af80fa4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -136,6 +136,8 @@ then pushd "$final_path" + ynh_use_nodejs + yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build popd From d0684041d80e3877d3fae92b3ed54e464b71b8bf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 21:58:57 +0200 Subject: [PATCH 56/67] Update install --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d73b3a9..a2fe4aa 100644 --- a/scripts/install +++ b/scripts/install @@ -138,7 +138,9 @@ pushd "$final_path" || ynh_die ynh_use_nodejs - yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build + yarn install --frozen-lockfile + + ynh_exec_warn_less yarn run build popd || ynh_die From 91018339bd17b853a139d51657ec83f19edeb815 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 31 May 2020 11:11:31 +0200 Subject: [PATCH 57/67] permissions --- scripts/install | 8 ++++++-- scripts/upgrade | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index a2fe4aa..c71780e 100644 --- a/scripts/install +++ b/scripts/install @@ -190,8 +190,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index af80fa4..61055b2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -182,6 +182,18 @@ yunohost service add $app --description "Collaborative Markdown notes" --log="/v # Set permissions on app files chown -R $app:$app $final_path +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi + #================================================= # START SYSTEMD SERVICE #================================================= From 820f6b3feb02611be5741b34b78817cedb52536a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 2 Jun 2020 15:04:15 +0200 Subject: [PATCH 58/67] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 61055b2..0d90702 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,7 +185,7 @@ chown -R $app:$app $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] From 78d817738c12ef22276a82a6245ddd79c77ca649 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Jun 2020 09:43:47 +0200 Subject: [PATCH 59/67] Improve descriptions --- README.md | 10 +++++----- README_fr.md | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 268587c..3eb4ec6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview -Collaborative editor to work on notes written in Markdown. +CodiMD is a real-time collaborative word processing web service. It uses Markdown language. **Shipped version:** 1.6.0 @@ -24,7 +24,7 @@ Collaborative editor to work on notes written in Markdown. ## Configuration -If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` file using this [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) +You can configure CodiMD by editing this file `/var/www/codimd/config.json` using this the [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) ## Documentation @@ -35,12 +35,12 @@ If you need to configure CodiMD, you can tweak `/var/www/codimd/config.json` fil #### Multi-users support -* Is LDAP supported? Yes -* Can the app be used by multiple users? Yes +* Is LDAP supported? **Yes** +* Can the app be used by multiple users? **Yes** #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) ## Limitations diff --git a/README_fr.md b/README_fr.md index 5c61c1b..df60c3a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -9,7 +9,8 @@ Si vous n’avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l’installer.* ## Vue d’ensemble -Éditeur collaboratif pour travailler sur des notes en Markdown. + +CodiMD est un service web de traitement de texte collaboratif en temps réel. Il utilise le langage Markdown. **Version incluse:** 1.6.0 @@ -23,7 +24,7 @@ Si vous n’avez pas YunoHost, consultez [le guide](https://yunohost.org/#/insta ## Configuration -Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/codimd/config.json` en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) +Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.json` et en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration-config-file.md) ## Documentation @@ -34,12 +35,12 @@ Si vous voulez configurer CodiMD, vous pouvez modifier votre fichier `/var/www/c #### Support multi-utilisateurs -* L’authentification LDAP est-elle prise en charge ? Oui -* L’application peut-elle être utilisée par plusieurs utilisateurs ? Oui +* L’authentification LDAP est-elle prise en charge ? **Oui** +* L’application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** #### Architectures supportées -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) ## Limitations From 1b29111b0982e9199de2399386a8a06f7bf09d01 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 9 Jun 2020 11:13:54 +0200 Subject: [PATCH 60/67] Update install --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index c71780e..a4768b7 100644 --- a/scripts/install +++ b/scripts/install @@ -137,9 +137,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd "$final_path" || ynh_die ynh_use_nodejs - yarn install --frozen-lockfile - ynh_exec_warn_less yarn run build popd || ynh_die From bf4dc9ba64c3aff89817a86fcba6dce03d51079a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 9 Jun 2020 11:14:01 +0200 Subject: [PATCH 61/67] Update upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0d90702..b0c4f00 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,8 +137,8 @@ then pushd "$final_path" ynh_use_nodejs - - yarn install --frozen-lockfile && ynh_exec_warn_less yarn run build + yarn install --frozen-lockfile + ynh_exec_warn_less yarn run build popd fi From 132501527d2d25e0a575958d94f278b702213c1c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 9 Jun 2020 11:17:29 +0200 Subject: [PATCH 62/67] Create issue_template.md --- issue_template.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 issue_template.md diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..ee8a72f --- /dev/null +++ b/issue_template.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to CodiMD itself. Refer to its documentation or repository for help.* + - *If you have a doubt, post here, we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +**Describe the bug** +*A clear and concise description of what the bug is.* + +**Versions** +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info codimd`* + +**To Reproduce** +*Steps to reproduce the behavior.* +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install codimd + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +**Expected behavior** +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +**Logs** +*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +*If applicable and useful, add screenshots to help explain your problem.* From 8949f2f103f3c7d42ed51377159f1a7fecde800d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 9 Jun 2020 11:18:57 +0200 Subject: [PATCH 63/67] Remove not needed variables --- scripts/change_url | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 5689c59..754711f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,11 +29,6 @@ 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) -# Add settings here as needed by your application -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From 962c6bbb87bb4b0dafe072822d5995115b24d6d7 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 9 Jun 2020 11:21:31 +0200 Subject: [PATCH 64/67] Update config.json.example --- conf/config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.json.example b/conf/config.json.example index 51f55c1..3a8e0fc 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -39,7 +39,7 @@ "usernameField": "cn", "useridField": "uid", "providerName": "YunoHost" - } + } } } From d63f6217d0d88f760918e24d395180b08f02197b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 10 Jun 2020 15:01:34 +0200 Subject: [PATCH 65/67] add buster badge --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 3eb4ec6..07c9e4e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) +* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) ## Limitations diff --git a/README_fr.md b/README_fr.md index df60c3a..c0d1c58 100644 --- a/README_fr.md +++ b/README_fr.md @@ -42,6 +42,7 @@ Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.js * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) +* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) ## Limitations From 6c5bd4242c722263d87646cce220c44e60136a82 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 10 Jun 2020 16:21:40 +0200 Subject: [PATCH 66/67] typo --- README.md | 2 +- README_fr.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07c9e4e..5847eac 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) -* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) +* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) ## Limitations diff --git a/README_fr.md b/README_fr.md index c0d1c58..be14170 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,14 +5,14 @@ *[Read this readme in english.](./README.md)* -> *Ce package vous permet d’installer CodiMD rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d’installer CodiMD rapidement et simplement sur un serveur YunoHost. Si vous n’avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l’installer.* ## Vue d’ensemble CodiMD est un service web de traitement de texte collaboratif en temps réel. Il utilise le langage Markdown. -**Version incluse:** 1.6.0 +**Version incluse :** 1.6.0 ## Captures d’écran @@ -42,7 +42,7 @@ Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.js * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) -* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) +* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) ## Limitations From 746962bf021b5ff7e4da8a638ba08dd2b6995408 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Jun 2020 16:12:37 +0200 Subject: [PATCH 67/67] Apply last example_ynh (#1) * Apply last example_ynh * fix db_user * Fix service start --- README.md | 16 ++---- README_fr.md | 26 ++++----- conf/systemd.service | 2 +- manifest.json | 3 +- scripts/_common.sh | 12 ++++ scripts/backup | 20 ++++--- scripts/change_url | 3 +- scripts/install | 130 ++++++++++++++++++++++++------------------- scripts/remove | 12 ++-- scripts/restore | 17 +++--- scripts/upgrade | 110 +++++++++++++++++++----------------- 11 files changed, 194 insertions(+), 157 deletions(-) diff --git a/README.md b/README.md index 5847eac..12dbc06 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,10 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install CodiMD quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install CodiMD quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview - CodiMD is a real-time collaborative word processing web service. It uses Markdown language. **Shipped version:** 1.6.0 @@ -33,7 +32,7 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin ## YunoHost specific features -#### Multi-users support +#### Multi-user support * Is LDAP supported? **Yes** * Can the app be used by multiple users? **Yes** @@ -42,11 +41,6 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) -* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) - -## Limitations - -## Additional information ## Links @@ -56,10 +50,10 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin --- -Developers info +Developer info ---------------- -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). To try the testing branch, please proceed like that. ``` diff --git a/README_fr.md b/README_fr.md index be14170..87ab9ea 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,20 +1,19 @@ # CodiMD pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) [![Installer CodiMD avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d’installer CodiMD rapidement et simplement sur un serveur YunoHost. -Si vous n’avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l’installer.* - -## Vue d’ensemble +> *Ce package vous permet d'installer CodiMD rapidement et simplement sur un serveur Yunohost. +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* +## Vue d'ensemble CodiMD est un service web de traitement de texte collaboratif en temps réel. Il utilise le langage Markdown. **Version incluse :** 1.6.0 -## Captures d’écran +## Captures d'écran ![](https://demo.codimd.org/screenshot.png) @@ -33,25 +32,20 @@ Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.js ## Caractéristiques spécifiques YunoHost -#### Support multi-utilisateurs +#### Support multi-utilisateur -* L’authentification LDAP est-elle prise en charge ? **Oui** -* L’application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** +* L'authentification LDAP est-elle prise en charge ? **Oui** +* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) -* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) - -## Limitations - -## Informations additionnelles ## Liens * Signaler un bug : https://github.com/YunoHost-Apps/codimd_ynh/issues - * Dépôt de l’application principale : https://github.com/codimd/server/ + * Dépôt de l'application principale : https://github.com/codimd/server/ * Site web YunoHost : https://yunohost.org/ --- diff --git a/conf/systemd.service b/conf/systemd.service index 6797ec1..53450d9 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,7 +10,7 @@ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" -ExecStart=/usr/bin/yarn start +ExecStart=__YNH_NPM__ start Restart=always PrivateTmp=true PrivateDevices=true diff --git a/manifest.json b/manifest.json index e6e1b74..0ceb6c1 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,8 @@ "nginx" ], "arguments": { - "install": [{ + "install" : [ + { "name": "domain", "type": "domain", "ask": { diff --git a/scripts/_common.sh b/scripts/_common.sh index b0b3f5f..4804c27 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,3 +8,15 @@ pkg_dependencies="postgresql apt-transport-https" nodejs_version=10 + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index b342a14..7065f73 100644 --- a/scripts/backup +++ b/scripts/backup @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= + ynh_clean_setup () { ynh_clean_check_starting } @@ -31,11 +32,14 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +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="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -43,13 +47,6 @@ ynh_backup --src_path=$final_path ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE DATABASE -#================================================= -ynh_print_info --message="Backing up the database..." - -ynh_psql_dump_db --database=$db_name > db.sql - #================================================= # SPECIFIC BACKUP #================================================= @@ -64,6 +61,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the Postgresql database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 754711f..9b97276 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC START +# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -107,6 +107,7 @@ fi #================================================= 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" #================================================= diff --git a/scripts/install b/scripts/install index a4768b7..60be9fe 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting } - # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,23 +23,34 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -app=$YNH_APP_INSTANCE_NAME - domain=$YNH_APP_ARG_DOMAIN path_url="/" 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 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +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 +ynh_app_setting_set --app=$app --key=is_public --value=$is_public + +#================================================= +# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= @@ -51,18 +61,8 @@ port=$(ynh_find_port --port=3000) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= -# 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 -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - -#============================================== # INSTALL DEPENDENCIES -#============================================== +#================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_install_app_dependencies $pkg_dependencies @@ -73,18 +73,17 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn 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 DB -#============================================== -ynh_script_progression --message="Creating a database..." --weight=2 +#================================================= +# CREATE A POSTGRESQL DATABASE +#================================================= +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_user --value=$db_user +ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -94,6 +93,7 @@ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path @@ -106,29 +106,15 @@ ynh_script_progression --message="Configuring Nginx web server..." --weight=2 ynh_add_nginx_config #================================================= -# MODIFY A CONFIG FILE +# CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" - -cp ../conf/config.json.example "$final_path/config.json" - -ynh_store_file_checksum "$final_path/config.json" - -# DB Config File -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" - -cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path +#================================================= +# SPECIFIC SETUP #============================================== # INSTALL CODIMD #============================================== @@ -142,16 +128,54 @@ pushd "$final_path" || ynh_die popd || ynh_die +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" + +ynh_add_systemd_config + +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." + +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" + +cp ../conf/config.json.example "$final_path/config.json" + +ynh_store_file_checksum --file="$final_path/config.json" + +# DB Config File +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" + +cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" + +ynh_store_file_checksum --file="$final_path/.sequelizerc" + #================================================= # GENERIC FINALIZATION #================================================= -# CREATE DEDICATED USER +# SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_script_progression --message="Securing files and directories..." +# Set permissions to app files chown -R $app:$app $final_path #================================================= @@ -163,24 +187,18 @@ ynh_script_progression --message="Configuring log rotation..." --weight=2 ynh_use_logrotate #================================================= -# SETUP SYSTEMD +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - -ynh_add_systemd_config +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app..." --weight=2 +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" #================================================= diff --git a/scripts/remove b/scripts/remove index 0d524ee..d9cd71a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,9 +18,9 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE @@ -44,9 +44,9 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the database..." --weight=2 +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=$db_user --db_name=$db_name @@ -64,10 +64,10 @@ ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=6 +ynh_script_progression --message="Removing app main directory..." --weight=6 # Remove the app directory securely -ynh_secure_remove --file=$final_path +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index dc72ab7..cbba363 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,8 @@ 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) -port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= @@ -49,6 +48,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -57,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=60 -ynh_restore_file --origin_path=$final_path +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER @@ -70,6 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app:$app $final_path @@ -84,15 +85,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=7 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - #================================================= -# RESTORE THE DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the database..." --weight=6 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -109,6 +111,7 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "collaborative Markdown editor" --log "/var/log/$app/$app.log" diff --git a/scripts/upgrade b/scripts/upgrade index b0c4f00..62a91f3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,12 +23,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -58,6 +59,7 @@ 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=160 @@ -81,11 +83,55 @@ then # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" - fi +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading Nginx web server configuration..." --weight=2 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=18 + +ynh_install_app_dependencies $pkg_dependencies + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +# Install Yarn +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 +#================================================= +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 + #================================================= # SPECIFIC UPGRADE +#============================================== +# INSTALL CODIMD +#============================================== +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=160 + + pushd "$final_path" || ynh_die + + ynh_use_nodejs + yarn install --frozen-lockfile + ynh_exec_warn_less yarn run build + + popd || ynh_die +fi + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -107,52 +153,6 @@ cp ../conf/config.json.example "$final_path/config.json" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/config.json" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading Nginx web server configuration..." --weight=2 - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=18 - -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - -ynh_install_app_dependencies $pkg_dependencies - -#============================================== -# INSTALL CODIMD -#============================================== -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=160 - - pushd "$final_path" - - ynh_use_nodejs - yarn install --frozen-lockfile - ynh_exec_warn_less yarn run build - - popd -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 - -#================================================= -# SPECIFIC UPGRADE #================================================= # SETUP LOGROTATE #================================================= @@ -170,14 +170,17 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" +# Create a dedicated systemd config ynh_add_systemd_config -yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" - +#================================================= +# GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:$app $final_path @@ -194,6 +197,13 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" + #================================================= # START SYSTEMD SERVICE #=================================================