diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 94% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index f08b4b9..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -8,10 +8,10 @@ about: When creating a bug report, please use the following template to provide 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 facilmap itself. Refer to its documentation or repository for help.* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* ---- +--- ### Describe the bug @@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install facilmap + sudo yunohost app install the_app ``` - *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:* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index 4c610bc..01696d6 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,41 @@ -# FacilMap for YunoHost + + +# Facilmap for YunoHost [![Integration level](https://dash.yunohost.org/integration/facilmap.svg)](https://dash.yunohost.org/appci/app/facilmap) ![](https://ci-apps.yunohost.org/ci/badges/facilmap.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/facilmap.maintain.svg) -[![Install facilmap with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=facilmap) +[![Install Facilmap with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=facilmap) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install FacilMap quickly and simply on a YunoHost server. +> *This package allows you to install Facilmap 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 -[FacilMap](https://github.com/FacilMap/facilmap) is a privacy-friendly, open-source versatile online map that combines different services based on OpenStreetMap and makes it easy to find places, plan routes and create custom maps full of markers, lines and routes, allowing live collaboration. Think of it like [Etherpad](https://etherpad.org/), just for maps. +Collaborative maps and routing with a straightforward interface -**Shipped version:** 3.1.0 +**Shipped version:** 3.3.0~ynh1 +**Demo:** https://facilmap.org/ ## Screenshots -![](https://wiki.openstreetmap.org/w/images/7/7a/FacilMap.png) +![](./doc/screenshots/screenshot.png) +## Documentation and resources -## Demo - -* [Official demo](https://facilmap.org/) - - -## Documentation - - * Official documentation: https://docs.facilmap.org/ - - -## YunoHost specific features - -#### Multi-user support - -The app doesn't require any login, anyone can use it, unless you install it privately. - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/facilmap%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/facilmap/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/facilmap%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/facilmap/) - - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/facilmap_ynh/issues - * App website: https://facilmap.org - * Upstream app repository: https://github.com/FacilMap/facilmap - * YunoHost website: https://yunohost.org/ - ---- - +* Official app website: https://facilmap.org/ +* Official user documentation: https://docs.facilmap.org/users/ +* Official admin documentation: https://docs.facilmap.org/developers/ +* Upstream app code repository: https://github.com/FacilMap/facilmap +* YunoHost documentation for this app: https://yunohost.org/app_facilmap +* Report a bug: https://github.com/YunoHost-Apps/facilmap_ynh/issues ## Developer info -**Only if you want to use a testing branch for coding, instead of merging directly into master.** Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/facilmap_ynh/tree/testing). To try the testing branch, please proceed like that. @@ -64,3 +44,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/facilmap_ynh/tree/tes or sudo yunohost app upgrade facilmap -u https://github.com/YunoHost-Apps/facilmap_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 6a9cd9d..6d6eac7 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,61 +1,37 @@ -# FacilMap pour YunoHost +# Facilmap pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/facilmap.svg)](https://dash.yunohost.org/appci/app/facilmap) ![](https://ci-apps.yunohost.org/ci/badges/facilmap.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/facilmap.maintain.svg) -[![Installer facilmap avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=facilmap) +[![Installer Facilmap avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=facilmap) *[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer facilmap 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.* - +> *Ce package vous permet d'installer Facilmap 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 -[FacilMap](https://github.com/FacilMap/facilmap) est une carte interactive polyvalente, libre et respectueuse de la vie privée qui regroupe des nombreux services basés sur les données libres de OpenStreetMap. FacilMap permet de naviguer, chercher et dessiner facilement des trajets, créer des cartes collaboratives qui peuvent être éditées par plusieurs personnes simultanément, similairement à ce qu'[Etherpad](http://etherpad.org/) propose pour l'édition collaborative de texte. +Carte collaborative avec une interface simple et pratique -**Version incluse :** 3.1.0 +**Version incluse :** 3.3.0~ynh1 +**Démo :** https://facilmap.org/ ## Captures d'écran -![](https://wiki.openstreetmap.org/w/images/7/7a/FacilMap.png) +![](./doc/screenshots/screenshot.png) +## Documentations et ressources -## Démo - -* [Démo officielle](https://facilmap.org/) - - -## Documentation - - * Documentation officielle (en Anglais) : https://docs.facilmap.org/ - - -## Caractéristiques spécifiques YunoHost - -#### Support multi-utilisateur - -Aucun login ou compte n'est nécessaire pour utiliser l'application, elle est utilisable par n'importe qui, à moins de l'installer de manière privée. - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/facilmap%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/facilmap/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/facilmap%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/facilmap/) - - -## Liens - - * Signaler un bug : https://github.com/YunoHost-Apps/facilmap_ynh/issues - * Site de l'application : https://facilmap.org - * Dépôt de l'application principale : https://github.com/FacilMap/facilmap - * Site web YunoHost : https://yunohost.org/ - ---- - +* Site officiel de l'app : https://facilmap.org/ +* Documentation officielle utilisateur : https://docs.facilmap.org/users/ +* Documentation officielle de l'admin : https://docs.facilmap.org/developers/ +* Dépôt de code officiel de l'app : https://github.com/FacilMap/facilmap +* Documentation YunoHost pour cette app : https://yunohost.org/app_facilmap +* Signaler un bug : https://github.com/YunoHost-Apps/facilmap_ynh/issues ## Informations pour les développeurs -**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/facilmap_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. @@ -64,3 +40,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/facilmap_ynh/tree/tes ou sudo yunohost app upgrade facilmap -u https://github.com/YunoHost-Apps/facilmap_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index 232d16c..72f2d6b 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,3 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - ;; Test complet ; Manifest domain="domain.tld" @@ -8,7 +5,6 @@ is_public=1 ors_token="test" mapbox_token="test" - mapzen_token="test" maxmind_user_id="" maxmind_license_key="" user_agent="FacilMap (https://facilmap.org/, webmaster@example.org)" @@ -22,7 +18,6 @@ upgrade=1 backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email=squeak@eauchat.org diff --git a/conf/config.env b/conf/config.env index 77eed0e..216ab97 100644 --- a/conf/config.env +++ b/conf/config.env @@ -24,7 +24,7 @@ MAPBOX_TOKEN=__MAPBOX_TOKEN__ # MapZen is used for getting elevation information # Get an API key on https://mapzen.com/developers/sign_up -MAPZEN_TOKEN=__MAPZEN_TOKEN__ +#MAPZEN_TOKEN= # Maxmind configuration. If specified, the maxmind GeoLite2 database will be downloaded # for Geo IP lookup (to show the initial map state) and kept in memory. diff --git a/conf/nginx.conf b/conf/nginx.conf index 19aa92b..244e4cc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,3 +1,4 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { # Force usage of https @@ -23,5 +24,4 @@ location __PATH__/ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; more_clear_input_headers 'Accept-Encoding'; - } diff --git a/conf/systemd.service b/conf/systemd.service index 9ce2147..09bd16c 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,13 +1,13 @@ [Unit] -Description=Facilmap: collaborative maps with a straightforward interface +Description=Facilmap: collaborative maps After=network.target [Service] Type=simple -Environment=NODE_ENV=production -Environment=DOTENV_CONFIG_PATH=__FINALPATH__/etc/facilmap.env User=__APP__ Group=__APP__ +Environment=NODE_ENV=production +Environment=DOTENV_CONFIG_PATH=__FINALPATH__/etc/facilmap.env Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__FINALPATH__/bin/facilmap-server WorkingDirectory=__FINALPATH__ diff --git a/doc/DISLAIMER.md b/doc/DISLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/screenshot.png b/doc/screenshots/screenshot.png new file mode 100644 index 0000000..65fd8b1 Binary files /dev/null and b/doc/screenshots/screenshot.png differ diff --git a/manifest.json b/manifest.json index 65c02b1..0feacd2 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,16 @@ "en": "Collaborative maps and routing with a straightforward interface", "fr": "Carte collaborative avec une interface simple et pratique" }, - "version": "3.1.0~ynh1", + "version": "3.3.0~ynh1", "url": "https://github.com/FacilMap/facilmap", + "upstream": { + "license": "AGPL-3.0", + "website": "https://facilmap.org/", + "demo": "https://facilmap.org/", + "admindoc": "https://docs.facilmap.org/developers/", + "userdoc": "https://docs.facilmap.org/users/", + "code": "https://github.com/FacilMap/facilmap" + }, "license": "AGPL-3.0", "maintainer": { "name": "Squeak", @@ -15,7 +23,7 @@ "url": "https://squeak.eauchat.org" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.2.4" }, "multi_instance": true, "services": [ @@ -52,8 +60,8 @@ "name": "ors_token", "type": "string", "help": { - "en": "OpenRouteService is used for calculating routes with advanced settings. You can get a token on https://go.openrouteservice.org/", - "fr": "OpenRouteService est utilisé pour calculer les routes complexes. Vous pouvez obtenir un token ici: https://go.openrouteservice.org/" + "en": "OpenRouteService is used for calculating routes with advanced settings. You can get a token on https://openrouteservice.org/", + "fr": "OpenRouteService est utilisé pour calculer les routes complexes. Vous pouvez obtenir un token ici: https://openrouteservice.org/" } }, { @@ -61,24 +69,15 @@ "type": "string", "help": { "en": "MapBox is used for calculating routes with simple settings. You can get an API key on https://www.mapbox.com/signup/", - "fr": "MapBox est utilisé pour calcluer les routes simples. Vous pouvez obtenir une clé API ici: https://www.mapbox.com/signup/" + "fr": "MapBox est utilisé pour calcluer les routes simples. Vous pouvez obtenir une clé API ici : https://www.mapbox.com/signup/" } }, - { - "name": "mapzen_token", - "type": "string", - "help": { - "en": "MapZen is used for getting elevation information. You can get an API key on https://mapzen.com/developers/sign_up", - "fr": "MapZen est utilisé pour obtenir les informations d'élévation. Vous pouvez obtenir une clé API ici: https://mapzen.com/developers/sign_up" - }, - "optional": true - }, { "name": "maxmind_user_id", "type": "string", "help": { "en": "Maxmind configuration. If specified, the maxmind GeoLite2 database will be downloaded for Geo IP lookup (to show the initial map state) and kept in memory. Sign up here: https://www.maxmind.com/en/geolite2/signup", - "fr": "Configuration maxmind. Si vous spécifiez ce champ et le prochain, la base de donnée maxmind GeoLite2 sera téléchargée puis gardée en mémoire, pour localiser les addresse IP (afin que le chargement de la carte se fasse centré là où l'utilisateur est). Vous pouvez créer un compte ici: https://www.maxmind.com/en/geolite2/signup" + "fr": "Configuration maxmind. Si vous spécifiez ce champ et le prochain, la base de donnée maxmind GeoLite2 sera téléchargée puis gardée en mémoire, pour localiser les addresse IP (afin que le chargement de la carte se fasse centré là où l'utilisateur est). Vous pouvez créer un compte ici : https://www.maxmind.com/en/geolite2/signup" }, "optional": true }, @@ -86,7 +85,7 @@ "name": "maxmind_license_key", "type": "string", "help": { - "en": "License key associated to the maxmind user id you specified.", + "en": "License key associated to the maxmind user ID you specified.", "fr": "La clé de license associée à l'utilisateur maxmind que vous avez spécifié." }, "optional": true @@ -95,8 +94,8 @@ "name": "user_agent", "type": "string", "help": { - "en": "HTTP requests made by the backend will send this User-Agent header. Fill here the url facilmap will have and your e-mail address.", - "fr": "Les requêtes faites par le serveur enveront cette entête User-agent. Remplissez ici l'url de votre instance facilmap et votre adresse email." + "en": "HTTP requests made by the backend will send this User-Agent header. Fill here the URL facilmap will have and your e-mail address.", + "fr": "Les requêtes faites par le serveur enveront cette entête User-agent. Remplissez ici l'URL de votre instance facilmap et votre adresse email." }, "example": "FacilMap (https://facilmap.org/, webmaster@example.org)" } diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## 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 ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/_common.sh b/scripts/_common.sh index 63e1450..398e25c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,7 +8,8 @@ pkg_dependencies="" nodejs_version=14 -facilmap_version=3.1.0 + +facilmap_version=3.3.0 #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index ff28e6a..ca47243 100755 --- a/scripts/backup +++ b/scripts/backup @@ -37,11 +37,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -73,9 +68,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= ynh_print_info --message="Backing up the MySQL database..." -### (However, things like MySQL dumps *do* take some time to run, though the -### copy of the generated dump to the archive still happens later) - ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= diff --git a/scripts/change_url b/scripts/change_url index a7a4dba..2de6c6f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,12 +28,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=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - port=$(ynh_app_setting_get --app=$app --key=port) #================================================= @@ -107,12 +101,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index bbd6497..08201b1 100755 --- a/scripts/install +++ b/scripts/install @@ -33,7 +33,6 @@ user_agent="$YNH_APP_ARG_USER_AGENT" # APIS TOKENS ors_token="$YNH_APP_ARG_ORS_TOKEN" mapbox_token="$YNH_APP_ARG_MAPBOX_TOKEN" -mapzen_token="$YNH_APP_ARG_MAPZEN_TOKEN" maxmind_user_id="$YNH_APP_ARG_MAXMIND_USER_ID" maxmind_license_key="$YNH_APP_ARG_MAXMIND_LICENSE_KEY" @@ -60,7 +59,6 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=user_agent --value=$user_agent ynh_app_setting_set --app=$app --key=ors_token --value=$ors_token ynh_app_setting_set --app=$app --key=mapbox_token --value=$mapbox_token -ynh_app_setting_set --app=$app --key=mapzen_token --value=$mapzen_token ynh_app_setting_set --app=$app --key=maxmind_user_id --value=$maxmind_user_id ynh_app_setting_set --app=$app --key=maxmind_license_key --value=$maxmind_license_key @@ -80,21 +78,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=6 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# INSTALL NODEJS -#================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=30 - ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -104,20 +88,25 @@ ynh_script_progression --message="Creating a MySQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd= # Will be set by facilmap_create_db +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_app_setting_set --app=$app --key=db_name --value=$db_name -facilmap_create_db +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +echo "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -#ynh_script_progression --message="Setting up source files..." --weight=100 +ynh_script_progression --message="Setting up source files..." --weight=100 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" - #================================================= # NGINX CONFIGURATION #================================================= @@ -126,14 +115,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -facilmap_create_user - #================================================= # SPECIFIC SETUP #================================================= @@ -141,7 +122,16 @@ facilmap_create_user #================================================= ynh_script_progression --message="Building node dependencies..." --weight=200 -facilmap_install_app +mkdir -p $final_path +chown -R $app $final_path + +pushd $final_path + ynh_exec_as $app "$ynh_node_load_PATH" $ynh_npm install --prefix "$final_path" -g facilmap-server@"$facilmap_version" 2>/dev/null +popd + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SETUP SYSTEMD @@ -149,24 +139,15 @@ facilmap_install_app ynh_script_progression --message="Configuring a systemd service..." --weight=2 # Create a dedicated systemd config -ynh_add_systemd_config --others_var="ynh_node_load_PATH" +ynh_add_systemd_config #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding configuration..." --weight=2 -facilmap_add_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Setting app files permissions.." --weight=2 - -# Set permissions on app files -facilmap_set_permissions +mkdir -p $final_path/etc +ynh_add_config --template="../conf/config.env" --destination="$final_path/etc/facilmap.env" #================================================= # SETUP LOGROTATE @@ -181,7 +162,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Collaborative maps and routing with a straightforward interface" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Collaborative maps and routing" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -199,22 +180,9 @@ ynh_script_progression --message="Configuring app permissions..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi -# ### N.B. : the following extra permissions only make sense if your app -# ### does have for example an admin interface or an api. -# -# # Only the admin can access the admin panel of the app (if the app has an admin panel) -# ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -# -# # Everyone can access to the api part -# # We don't want to display the tile in the sso so we put --show_tile="false" -# # And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true" -# ynh_permission_create --permission="api" --url "/api" --allowed="visitors" --show_tile="false" --protected="true" - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 949ef1b..06fb54b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -58,12 +58,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=3 # Remove metapackage and its dependencies ynh_remove_app_dependencies - -#================================================= -# REMOVE NODEJS -#================================================= -ynh_script_progression --message="Removing NodeJS version for facilmap..." --weight=4 - ynh_remove_nodejs #================================================= @@ -90,16 +84,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing log files..." --weight=1 - -# Remove the log files -ynh_secure_remove --file="/var/log/$app/" - #================================================= # GENERIC FINALIZATION #================================================= @@ -109,7 +93,6 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh # Delete a system user ynh_system_user_delete --username=$app -ynh_secure_remove --file="/home/$app/" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 76edbad..1ed2dab 100755 --- a/scripts/restore +++ b/scripts/restore @@ -51,13 +51,6 @@ test ! -d $final_path \ 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=2 - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -67,13 +60,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=2 -# Restore permissions on app files -chown -R root:root $final_path -mkdir -p "$final_path/lib/node_modules/facilmap-server/cache" -chown -R facilmap:facilmap "$final_path/lib/node_modules/facilmap-server/cache" +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION @@ -84,12 +79,6 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=10 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# REINSTALL NODEJS -#================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=30 - ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -98,8 +87,8 @@ ynh_install_nodejs --nodejs_version=$nodejs_version ynh_script_progression --message="Restoring the MySQL database..." --weight=5 db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - -facilmap_create_db +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +echo "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= @@ -115,7 +104,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Collaborative maps and routing with a straightforward interface" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Collaborative maps and routing" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -124,14 +113,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=5 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server started" -#================================================= -# RESTORE VARIOUS FILES -#================================================= - -#ynh_restore_file --origin_path="/etc/cron.d/$app" - -#ynh_restore_file --origin_path="/etc/$app/" - #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 209f4d8..2e29f94 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,7 +28,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) user_agent=$(ynh_app_setting_get --app=$app --key=user_agent) ors_token=$(ynh_app_setting_get --app=$app --key=ors_token) mapbox_token=$(ynh_app_setting_get --app=$app --key=mapbox_token) -mapzen_token=$(ynh_app_setting_get --app=$app --key=mapzen_token) maxmind_user_id=$(ynh_app_setting_get --app=$app --key=maxmind_user_id) maxmind_license_key=$(ynh_app_setting_get --app=$app --key=maxmind_license_key) @@ -62,16 +61,12 @@ 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 +# CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -#if [ "$upgrade_type" == "UPGRADE_APP" ] -#then -# ynh_script_progression --message="Upgrading source files..." --weight=5 -# -# # Download, check integrity, uncompress and patch the source from app.src -# ynh_setup_source --dest_dir="$final_path" -#fi +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # NGINX CONFIGURATION @@ -87,30 +82,22 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." --weight=10 ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# UPGRADE NODEJS -#================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=40 - ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -facilmap_create_user - #================================================= # SPECIFIC UPGRADE #================================================= # BUILD NODE DEPENDENCIES #================================================= -ynh_script_progression --message="Building node dependencies..." --weight=70 +ynh_script_progression --message="Install $app..." --weight=20 -facilmap_install_app +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + chown -R $app $final_path + pushd $final_path + ynh_exec_as $app "$ynh_node_load_PATH" $ynh_npm install --prefix "$final_path" -g facilmap-server@"$facilmap_version" 2>/dev/null + popd +fi #================================================= # SETUP SYSTEMD @@ -118,14 +105,15 @@ facilmap_install_app ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config -ynh_add_systemd_config --others_var="ynh_node_load_PATH" +ynh_add_systemd_config #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating config files..." --weight=2 -facilmap_add_config +mkdir -p "$final_path/etc" +ynh_add_config --template="../conf/config.env" --destination="$final_path/etc/facilmap.env" #================================================= # GENERIC FINALIZATION @@ -135,7 +123,9 @@ facilmap_add_config ynh_script_progression --message="Setting files permissions..." --weight=1 # Set permissions on app files -facilmap_set_permissions +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SETUP LOGROTATE @@ -150,7 +140,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Collaborative maps and routing with a straightforward interface" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Collaborative maps and routing" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE