diff --git a/README.md b/README.md index 5e240c1..f596c83 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,6 @@ LanguageTool is a multilingual grammar, style, and spell checker. This package p ![Screenshot of LanguageTool server](./doc/screenshots/screenshot_fr.png) ![Screenshot of LanguageTool server](./doc/screenshots/screenshot.png) -## Disclaimers / important information - -## Configuration - -There is a configuration file at `/var/www/languagetool/languagetool.conf` (for the first install). - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index bc0faf7..02ac460 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,12 +28,6 @@ LanguageTool est un correcteur d'orthographe, de grammaire et de style multiling ![Capture d’écran de LanguageTool server](./doc/screenshots/screenshot_fr.png) ![Capture d’écran de LanguageTool server](./doc/screenshots/screenshot.png) -## Avertissements / informations importantes - -## Configuration - -Il y a un fichier de configuration à `/var/www/languagetool/languagetool.conf` (pour la première installation). - ## Documentations et ressources * Site officiel de l’app : diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index e593236..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/LanguageTool-6.2.zip -SOURCE_SUM=1e8a10ac8e6c40c077c1640eb85fa9ca615a683fecdf7e00e51e463dcd0a0f49 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/beolingus.src b/conf/beolingus.src deleted file mode 100644 index 91be2f7..0000000 --- a/conf/beolingus.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://ftp.tu-chemnitz.de/pub/Local/urz/ding/de-en/de-en.txt.zip -SOURCE_SUM=e6b98900d5a700fc94e31139898a0700596477201c78ee860b13dfe9a67638fa -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=de-en.txt.zip -SOURCE_EXTRACT=true diff --git a/conf/fasttext-model-compressed.src b/conf/fasttext-model-compressed.src deleted file mode 100644 index 87ffb2d..0000000 --- a/conf/fasttext-model-compressed.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftz -SOURCE_SUM=8f3472cfe8738a7b6099e8e999c3cbfae0dcd15696aac7d7738a8039db603e83 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=bin -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=lid.176.ftz -SOURCE_EXTRACT=false diff --git a/conf/fasttext-model.src b/conf/fasttext-model.src deleted file mode 100644 index 941c363..0000000 --- a/conf/fasttext-model.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin -SOURCE_SUM=7e69ec5451bc261cc7844e49e4792a85d7f09c06789ec800fc4a44aec362764e -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=bin -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=lid.176.bin -SOURCE_EXTRACT=false diff --git a/conf/fasttext.src b/conf/fasttext.src deleted file mode 100644 index 6315df3..0000000 --- a/conf/fasttext.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/facebookresearch/fastText/archive/refs/tags/v0.9.2.tar.gz -SOURCE_SUM=7ea4edcdb64bfc6faaaec193ef181bdc108ee62bb6a04e48b2e80b639a99e27e -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=v0.9.2.tar.gz -SOURCE_EXTRACT=true diff --git a/conf/ngram-he.src b/conf/ngram-he.src deleted file mode 100644 index 3735016..0000000 --- a/conf/ngram-he.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/untested/ngram-he-20150916.zip -SOURCE_SUM=8f520d4f24214fe892d646edfa7ec6f9a0bf6b67749a87ef5cc565892ec60410 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngram-he-20150916.zip -SOURCE_EXTRACT=true diff --git a/conf/ngram-it.src b/conf/ngram-it.src deleted file mode 100644 index eaa0e1c..0000000 --- a/conf/ngram-it.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/untested/ngram-it-20150915.zip -SOURCE_SUM=092eeb91d138b808ad3e9b7e98973da503f824caf8a943c41c8700126b11f9f9 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngram-it-20150915.zip -SOURCE_EXTRACT=true diff --git a/conf/ngram-ru.src b/conf/ngram-ru.src deleted file mode 100644 index 38dc99c..0000000 --- a/conf/ngram-ru.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/untested/ngram-ru-20150914.zip -SOURCE_SUM=c6d047c944da78998ea014c9fcd516022bdfded1e4fe0f32cf48fa5a6e686e2c -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngram-ru-20150914.zip -SOURCE_EXTRACT=true diff --git a/conf/ngram-zh.src b/conf/ngram-zh.src deleted file mode 100644 index 2b66afc..0000000 --- a/conf/ngram-zh.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/untested/ngram-zh-20150916.zip -SOURCE_SUM=8217230df12b7515b144fe28b143dc0600c0613caa619813f6a2fac5fe416509 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngram-zh-20150916.zip -SOURCE_EXTRACT=true diff --git a/conf/ngrams-de.src b/conf/ngrams-de.src deleted file mode 100644 index 99a96de..0000000 --- a/conf/ngrams-de.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/ngrams-de-20150819.zip -SOURCE_SUM=b338ded55f16a00a36cdf41db9234b03000fb750517e5380cfd4d10cb14f72b0 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngrams-de-20150819.zip -SOURCE_EXTRACT=true diff --git a/conf/ngrams-en.src b/conf/ngrams-en.src deleted file mode 100644 index 0385fba..0000000 --- a/conf/ngrams-en.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/ngrams-en-20150817.zip -SOURCE_SUM=10e548731d9f58189fc36a553f7f685703be30da0d9bb42d1f7b5bf5f8bb232c -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngrams-en-20150817.zip -SOURCE_EXTRACT=true diff --git a/conf/ngrams-es.src b/conf/ngrams-es.src deleted file mode 100644 index d282c0a..0000000 --- a/conf/ngrams-es.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/ngrams-es-20150915.zip -SOURCE_SUM=f4010e0d92a1c49e87f9265f85be9b1d419f6e99eea603358e7917ba65b74cce -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngrams-es-20150915.zip -SOURCE_EXTRACT=true diff --git a/conf/ngrams-fr.src b/conf/ngrams-fr.src deleted file mode 100644 index 2880f18..0000000 --- a/conf/ngrams-fr.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/ngrams-fr-20150913.zip -SOURCE_SUM=6e591d5b301b76d595342217bddda6804e515307ef28019d7256efadbd5880cd -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngrams-fr-20150913.zip -SOURCE_EXTRACT=true diff --git a/conf/ngrams-nl.src b/conf/ngrams-nl.src deleted file mode 100644 index 67db519..0000000 --- a/conf/ngrams-nl.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://languagetool.org/download/ngram-data/ngrams-nl-20181229.zip -SOURCE_SUM=e32afafa2a6a456d9e3fdb28bdbcaa1f783ccad1b21dbdb8f8ba90656366b8bb -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ngrams-nl-20181229.zip -SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 427f691..1e7710b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port __PORT__ --config __FINALPATH__/languagetool.conf +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port __PORT__ --config __INSTALL_DIR__/languagetool.conf StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 45b73d9..0000000 --- a/manifest.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "name": "LanguageTool server", - "id": "languagetool", - "packaging_format": 1, - "description": { - "en": "Multilingual grammar, style, and spell checker (API)", - "fr": "Correcteur d'orthographe, de grammaire et de style multilingue (API)" - }, - "version": "6.2~ynh1", - "url": "https://languagetool.org", - "upstream": { - "license": "LGPL-2.1-only", - "website": "https://languagetool.org", - "demo": "https://api.languagetool.org/", - "admindoc": "https://dev.languagetool.org/", - "code": "https://github.com/languagetool-org/languagetool" - }, - "license": "LGPL-2.1-only", - "maintainer": { - "name": "Jules Bertholet", - "email": "jules.bertholet@gmail.com" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "use_ngram", - "type": "boolean", - "ask": { - "en": "Use ngram data (de, en, es, fr, nl)?", - "fr": "Utilizer donnés ngram (de, en, es, fr, nl) ?" - }, - "help": { - "en": "~15.4 GB download", - "fr": "Téléchargement de ~15,4 Go" - }, - "default": true - }, - { - "name": "use_untested_ngram", - "type": "boolean", - "ask": { - "en": "Use untested ngram data (he, it, ru, zh)? (requires above option)", - "fr": "Utilizer donnés ngram non testées (he, it, ru, zh) ? (nécessite l'option ci-dessus)" - }, - "help": { - "en": "~5.3 GB download", - "fr": "Téléchargement de ~5,3 Go" - }, - "default": false - }, - { - "name": "use_fasttext", - "type": "boolean", - "ask": { - "en": "Use fastext for language detection?", - "fr": "Utilizer fasttext pour la détection de langue ?" - }, - "help": { - "en": "~131 MB download", - "fr": "Téléchargement de ~131 Mo" - }, - "default": true - }, - { - "name": "use_compressed_fasttext", - "type": "boolean", - "ask": { - "en": "Use compressed fastext model?", - "fr": "Utilizer modéle fasttext compressé ?" - }, - "help": { - "en": "Reduces fasttex model download to ~938 KB, but slower and less accurate", - "fr": "Réduit la taille du téléchargement du modéle fasttext à ~938 Ko, mais moins rapide et précis" - }, - "default": false - }, - { - "name": "use_beolingus", - "type": "boolean", - "ask": { - "en": "Use Beolingus German-English word list?", - "fr": "Utilizer liste de mots allemand-anglais Beolingus?" - }, - "help": { - "en": "~8 MB, download", - "fr": "Téléchargement de ~8 MB" - }, - "default": false - }, - { - "name": "grammalecte_server", - "type": "string", - "ask": { - "en": "Grammalecte server URL (optional, adds additional French-language rules if specified)", - "fr": "URL de serveur Grammalecte (facultatif, ajoute des régles pour la langue française si specifié)" - }, - "help": { - "en": "You can add a Grammalecte server to your YunoHost installation with the dedicated package (https://github.com/YunoHost-Apps/grammalecte_ynh)", - "fr": "Vous pouvez ajouter un serveur Grammalecte à votre installation YunoHost avec le paquet dedié (https://github.com/YunoHost-Apps/grammalecte_ynh)" - }, - "example": "https://grammalecte.example.com", - "default": "", - "optional": true - } - ] - } -} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..26adbd4 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,185 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "languagetool" +name = "LanguageTool server" +description.en = "Multilingual grammar, style, and spell checker (API)" +description.fr = "Correcteur d'orthographe, de grammaire et de style multilingue (API)" + +version = "6.2~ynh1" + +maintainers = ["Jules Bertholet"] + +[upstream] +license = "LGPL-2.1-only" +website = "https://languagetool.org" +demo = "https://api.languagetool.org/" +admindoc = "https://dev.languagetool.org/" +code = "https://github.com/languagetool-org/languagetool" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "1G" +ram.build = "50M" +ram.runtime = "800M" + +[install] + [install.domain] + type = "domain" + + [install.init_main_permission] + help.en = "Should the login be exposed to public?" + help.fr = "La connexion doit-elle être exposée au public ?" + type = "group" + default = "visitors" + + [install.use_ngram] + ask.en = "Use ngram data (de, en, es, fr, nl)?" + ask.fr = "Utilizer donnés ngram (de, en, es, fr, nl) ?" + help.en = "~15.4 GB download" + help.fr = "Téléchargement de ~15,4 Go" + type = "boolean" + default = true + + [install.use_untested_ngram] + ask.en = "Use untested ngram data (he, it, ru, zh)? (requires above option)" + ask.fr = "Utilizer donnés ngram non testées (he, it, ru, zh) ? (nécessite l'option ci-dessus)" + help.en = "~5.3 GB download" + help.fr = "Téléchargement de ~5,3 Go" + type = "boolean" + default = false + + [install.use_fasttext] + ask.en = "Use fastext for language detection?" + ask.fr = "Utilizer fasttext pour la détection de langue ?" + help.en = "~131 MB download" + help.fr = "Téléchargement de ~131 Mo" + type = "boolean" + default = true + + [install.use_compressed_fasttext] + ask.en = "Use compressed fastext model?" + ask.fr = "Utilizer modéle fasttext compressé ?" + help.en = "Reduces fasttex model download to ~938 KB, but slower and less accurate" + help.fr = "Réduit la taille du téléchargement du modéle fasttext à ~938 Ko, mais moins rapide et précis" + type = "boolean" + default = false + + [install.use_beolingus] + ask.en = "Use Beolingus German-English word list?" + ask.fr = "Utilizer liste de mots allemand-anglais Beolingus?" + help.en = "~8 MB, download" + help.fr = "Téléchargement de ~8 MB" + type = "boolean" + default = false + + [install.grammalecte_server] + ask.en = "Grammalecte server URL (optional, adds additional French-language rules if specified)" + ask.fr = "URL de serveur Grammalecte (facultatif, ajoute des régles pour la langue française si specifié)" + help.en = "You can add a Grammalecte server to your YunoHost installation with the dedicated package (https://github.com/YunoHost-Apps/grammalecte_ynh)" + help.fr = "Vous pouvez ajouter un serveur Grammalecte à votre installation YunoHost avec le paquet dedié (https://github.com/YunoHost-Apps/grammalecte_ynh)" + type = "string" + example = "https://grammalecte.example.com" + default = "" + optional = true + +[resources] + [resources.sources] + [resources.sources.main] + url = "https://languagetool.org/download/LanguageTool-6.2.zip" + sha256 = "1e8a10ac8e6c40c077c1640eb85fa9ca615a683fecdf7e00e51e463dcd0a0f49" + + [resources.sources.ngrams-de] + url = "https://languagetool.org/download/ngram-data/ngrams-de-20150819.zip" + sha256 = "b338ded55f16a00a36cdf41db9234b03000fb750517e5380cfd4d10cb14f72b0" + prefetch = false + + [resources.sources.ngrams-en] + url = "https://languagetool.org/download/ngram-data/ngrams-en-20150817.zip" + sha256 = "10e548731d9f58189fc36a553f7f685703be30da0d9bb42d1f7b5bf5f8bb232c" + prefetch = false + + [resources.sources.ngrams-es] + url = "https://languagetool.org/download/ngram-data/ngrams-es-20150915.zip" + sha256 = "f4010e0d92a1c49e87f9265f85be9b1d419f6e99eea603358e7917ba65b74cce" + prefetch = false + + [resources.sources.ngrams-fr] + url = "https://languagetool.org/download/ngram-data/ngrams-fr-20150913.zip" + sha256 = "6e591d5b301b76d595342217bddda6804e515307ef28019d7256efadbd5880cd" + prefetch = false + + [resources.sources.ngrams-nl] + url = "https://languagetool.org/download/ngram-data/ngrams-nl-20181229.zip" + sha256 = "e32afafa2a6a456d9e3fdb28bdbcaa1f783ccad1b21dbdb8f8ba90656366b8bb" + prefetch = false + + [resources.sources.ngram-he] + url = "https://languagetool.org/download/ngram-data/untested/ngram-he-20150916.zip" + sha256 = "8f520d4f24214fe892d646edfa7ec6f9a0bf6b67749a87ef5cc565892ec60410" + prefetch = false + + [resources.sources.ngram-it] + url = "https://languagetool.org/download/ngram-data/untested/ngram-it-20150915.zip" + sha256 = "092eeb91d138b808ad3e9b7e98973da503f824caf8a943c41c8700126b11f9f9" + prefetch = false + + [resources.sources.ngram-ru] + url = "https://languagetool.org/download/ngram-data/untested/ngram-ru-20150914.zip" + sha256 = "c6d047c944da78998ea014c9fcd516022bdfded1e4fe0f32cf48fa5a6e686e2c" + prefetch = false + + [resources.sources.ngram-zh] + url = "https://languagetool.org/download/ngram-data/untested/ngram-zh-20150916.zip" + sha256 = "8217230df12b7515b144fe28b143dc0600c0613caa619813f6a2fac5fe416509" + prefetch = false + + [resources.sources.fasttext-model] + url = "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin" + sha256 = "7e69ec5451bc261cc7844e49e4792a85d7f09c06789ec800fc4a44aec362764e" + prefetch = false + format = "whatever" + extract = false + rename = "lid.176.bin" + + [resources.sources.fasttext-model-compressed] + url = "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftz" + sha256 = "8f3472cfe8738a7b6099e8e999c3cbfae0dcd15696aac7d7738a8039db603e83" + prefetch = false + format = "whatever" + extract = false + rename = "lid.176.ftz" + + [resources.sources.fasttext] + url = "https://github.com/facebookresearch/fastText/archive/refs/tags/v0.9.2.tar.gz" + sha256 = "7ea4edcdb64bfc6faaaec193ef181bdc108ee62bb6a04e48b2e80b639a99e27e" + prefetch = false + + [resources.sources.beolingus] + url = "https://ftp.tu-chemnitz.de/pub/Local/urz/ding/de-en/de-en.txt.zip" + sha256 = "e6b98900d5a700fc94e31139898a0700596477201c78ee860b13dfe9a67638fa" + prefetch = false + in_subdir = false + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 8081 + + [resources.apt] + packages = [ + "default-jre", + "build-essential", + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index bea3b28..1f56a74 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,110 +4,80 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="default-jre build-essential" - #================================================= # PERSONAL HELPERS #================================================= -function download_data { - if [ $use_ngram -eq 1 ]; then - ynh_setup_source --dest_dir="$data_path/ngrams/de" --source_id="ngrams-de" - ynh_setup_source --dest_dir="$data_path/ngrams/en" --source_id="ngrams-en" - ynh_setup_source --dest_dir="$data_path/ngrams/es" --source_id="ngrams-es" - ynh_setup_source --dest_dir="$data_path/ngrams/fr" --source_id="ngrams-fr" - ynh_setup_source --dest_dir="$data_path/ngrams/nl" --source_id="ngrams-nl" +download_data() { + if [ "$use_ngram" -eq 1 ]; then + ynh_setup_source --dest_dir="$data_dir/ngrams/de" --source_id="ngrams-de" + ynh_setup_source --dest_dir="$data_dir/ngrams/en" --source_id="ngrams-en" + ynh_setup_source --dest_dir="$data_dir/ngrams/es" --source_id="ngrams-es" + ynh_setup_source --dest_dir="$data_dir/ngrams/fr" --source_id="ngrams-fr" + ynh_setup_source --dest_dir="$data_dir/ngrams/nl" --source_id="ngrams-nl" - if [ $use_untested_ngram -eq 1 ]; then - ynh_setup_source --dest_dir="$data_path/ngrams/he" --source_id="ngram-he" - ynh_setup_source --dest_dir="$data_path/ngrams/it" --source_id="ngram-it" - ynh_setup_source --dest_dir="$data_path/ngrams/ru" --source_id="ngram-ru" - ynh_setup_source --dest_dir="$data_path/ngrams/zh" --source_id="ngram-zh" - fi - fi + if [ "$use_untested_ngram" -eq 1 ]; then + ynh_setup_source --dest_dir="$data_dir/ngrams/he" --source_id="ngram-he" + ynh_setup_source --dest_dir="$data_dir/ngrams/it" --source_id="ngram-it" + ynh_setup_source --dest_dir="$data_dir/ngrams/ru" --source_id="ngram-ru" + ynh_setup_source --dest_dir="$data_dir/ngrams/zh" --source_id="ngram-zh" + fi + fi - if [ $use_fasttext -eq 1 ]; then - if [ $use_compressed_fasttext -eq 1 ]; then - ynh_setup_source --dest_dir="$data_path/fasttext" --source_id="fasttext-model-compressed" - else - ynh_setup_source --dest_dir="$data_path/fasttext" --source_id="fasttext-model" - fi - ynh_setup_source --dest_dir="$final_path/fasttext" --source_id="fasttext" - fi + if [ "$use_fasttext" -eq 1 ]; then + if [ "$use_compressed_fasttext" -eq 1 ]; then + ynh_setup_source --dest_dir="$data_dir/fasttext" --source_id="fasttext-model-compressed" + else + ynh_setup_source --dest_dir="$data_dir/fasttext" --source_id="fasttext-model" + fi + ynh_setup_source --dest_dir="$install_dir/fasttext" --source_id="fasttext" + fi - if [ $use_beolingus -eq 1 ]; then - ynh_setup_source --dest_dir="$data_path/beolingus" --source_id="beolingus" - fi + if [ $use_beolingus -eq 1 ]; then + ynh_setup_source --dest_dir="$data_dir/beolingus" --source_id="beolingus" + fi } -function add_languagetool_config { - if [ $use_ngram -eq 1 ]; then - language_model_config_line="languageModel=$data_path/ngrams" - else - language_model_config_line="" - fi +add_languagetool_config() { + if [ "$use_ngram" -eq 1 ]; then + language_model_config_line="languageModel=$data_dir/ngrams" + else + language_model_config_line="" + fi - if [ $use_fasttext -eq 1 ]; then - if [ $use_compressed_fasttext -eq 1 ]; then - fasttext_model_config_line="fasttextModel=$data_path/fasttext/lid.176.ftz" - else - fasttext_model_config_line="fasttextModel=$data_path/fasttext/lid.176.bin" - fi - fasttext_binary_config_line="fasttextBinary=$final_path/fasttext/fasttext" - else - fasttext_model_config_line="" - fasttext_binary_config_line="" - fi + if [ "$use_fasttext" -eq 1 ]; then + if [ $use_compressed_fasttext -eq 1 ]; then + fasttext_model_config_line="fasttextModel=$data_dir/fasttext/lid.176.ftz" + else + fasttext_model_config_line="fasttextModel=$data_dir/fasttext/lid.176.bin" + fi + fasttext_binary_config_line="fasttextBinary=$install_dir/fasttext/fasttext" + else + fasttext_model_config_line="" + fasttext_binary_config_line="" + fi - if [ $use_beolingus -eq 1 ]; then - beolingus_file_config_line="beolingusFile=$data_path/beolingus/de-en.txt" - else - beolingus_file_config_line="" - fi + if [ "$use_beolingus" -eq 1 ]; then + beolingus_file_config_line="beolingusFile=$data_dir/beolingus/de-en.txt" + else + beolingus_file_config_line="" + fi - if [ ! -z $grammalecte_server ]; then - grammalecte_server_config_line="grammalecteServer=$grammalecte_server/gc_text/fr" - else - grammalecte_server_config_line="" - fi + if [ ! -z "$grammalecte_server" ]; then + grammalecte_server_config_line="grammalecteServer=$grammalecte_server/gc_text/fr" + else + grammalecte_server_config_line="" + fi - ynh_add_config --template="languagetool.conf" --destination="$final_path/languagetool.conf" + ynh_add_config --template="languagetool.conf" --destination="$install_dir/languagetool.conf" } -function compile_fasttext { - if [ $use_fasttext -eq 1 ]; then - ynh_script_progression --message="Compiling fasttext..." --weight=15 - - pushd "$final_path/fasttext" || ynh_die - chown -R $app:$app $final_path/fasttext - sudo -u $app make - chown -R root:root $final_path/fasttext - popd || ynh_die - fi -} - -function set_permissions { - chown -R root:$app $final_path - chmod -R g=u,g-w,o-rwx $final_path - chown -R root:$app $data_path - chmod -R g=u,g-w,o-rwx $data_path -} - -function load_installation_settings { - 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) - data_path=$(ynh_app_setting_get --app=$app --key=data_path) - use_ngram=$(ynh_app_setting_get --app=$app --key=use_ngram) - use_untested_ngram=$(ynh_app_setting_get --app=$app --key=use_untested_ngram) - use_fasttext=$(ynh_app_setting_get --app=$app --key=use_fasttext) - use_compressed_fasttext=$(ynh_app_setting_get --app=$app --key=use_compressed_fasttext) - use_beolingus=$(ynh_app_setting_get --app=$app --key=use_beolingus) - grammalecte_server=$(ynh_app_setting_get --app=$app --key=grammalecte_server) - port=$(ynh_app_setting_get --app=$app --key=port) +compile_fasttext() { + pushd "$install_dir/fasttext" + chown -R "$app:$app" $install_dir/fasttext + ynh_exec_as "$app" make -j "$(( $(nproc) * 3/4 ))" + chown -R root:root $install_dir/fasttext + popd } #================================================= diff --git a/scripts/backup b/scripts/backup index ec09318..54a7e09 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -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) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -40,32 +19,22 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE APP DATA DIR #================================================= -ynh_backup --src_path="$data_path" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup --src_path="/etc/logrotate.d/$app" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 0b1a438..566d6ef 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,59 +9,6 @@ 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="/" - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -load_installation_settings - -#================================================= -# BACKUP BEFORE CHANGE URL 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 () { - ynh_clean_check_starting - # 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 #================================================= @@ -69,36 +16,14 @@ 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 #================================================= 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 +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -107,14 +32,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 8be579c..b430454 100755 --- a/scripts/install +++ b/scripts/install @@ -9,104 +9,16 @@ 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 - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url='/' -use_ngram=$YNH_APP_ARG_USE_NGRAM -use_untested_ngram=$YNH_APP_ARG_USE_UNTESTED_NGRAM -use_fasttext=$YNH_APP_ARG_USE_FASTTEXT -use_compressed_fasttext=$YNH_APP_ARG_USE_COMPRESSED_FASTTEXT -use_beolingus=$YNH_APP_ARG_USE_BEOLINGUS -grammalecte_server=$YNH_APP_ARG_GRAMMALECTE_SERVER - -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 --message="This path already contains a folder" -data_path=/home/yunohost.app/$app -test ! -e "$data_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=1 - -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=use_ngram --value=$use_ngram -ynh_app_setting_set --app=$app --key=use_untested_ngram --value=$use_untested_ngram -ynh_app_setting_set --app=$app --key=use_fasttext --value=$use_fasttext -ynh_app_setting_set --app=$app --key=use_compressed_fasttext --value=$use_compressed_fasttext -ynh_app_setting_set --app=$app --key=use_beolingus --value=$use_beolingus -ynh_app_setting_set --app=$app --key=grammalecte_server --value=$grammalecte_server - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=8081) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=100 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path -ynh_app_setting_set --app=$app --key=data_path --value=$data_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" download_data -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # SPECIFIC SETUP #================================================= @@ -119,67 +31,43 @@ add_languagetool_config #================================================= # COMPILE FASTTEXT #================================================= - -compile_fasttext - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config +if [ "$use_fasttext" -eq 1 ]; then + ynh_script_progression --message="Compiling fasttext..." --weight=15 + compile_fasttext +fi #================================================= # SECURE FILES AND DIRECTORIES #================================================= # Set permissions to app files -chown -R root:$app $final_path -chmod -R g=u,g-w,o-rwx $final_path -chown -R root:$app $data_path -chmod -R g=u,g-w,o-rwx $data_path +chown -R root:$app $install_dir +chmod -R g=u,g-w,o-rwx $install_dir +chown -R root:$app $data_dir +chmod -R g=u,g-w,o-rwx $data_dir #================================================= -# GENERIC FINALIZATION +# SYSTEM CONFIGURATION #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Create a dedicated systemd config +ynh_add_systemd_config +yunohost service add "$app" --description="Multilingual grammar, style, and spell checker" --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Multilingual grammar, style, and spell checker" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Everyone can access the app. -# The "main" permission is automatically created before the install script. -ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 5174c14..b89740a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,94 +10,27 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -load_installation_settings - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE APP DATA DIR -#================================================= -ynh_script_progression --message="Removing app data directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$data_path" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= - # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index ef324cf..73c88de 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,129 +10,55 @@ 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 - -load_installation_settings - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " -test ! -d $data_path \ - || ynh_die --message="There is already a directory: $data_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" + +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE APP DATA DIR #================================================= ynh_script_progression --message="Restoring the app data directory..." --weight=30 -ynh_restore_file --origin_path="$data_path" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -if [ ! -d "$data_path" ]; then - add_languagetool_config +if [ ! -d "$data_dir" ]; then + add_languagetool_config fi -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -set_permissions +chown -R "$app:www-data" "$data_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE VARIOUS FILES -#================================================= -ynh_script_progression --message="Restoring various files..." - -ynh_restore_file --origin_path="/var/log/$app" - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Multilingual grammar, style, and spell checker" --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Multilingual grammar, style, and spell checker" --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="/var/log/$app/$app.log" +ynh_restore_file --origin_path="/var/log/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 7e2fb30..2b8eb1d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,37 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -load_installation_settings - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -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=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # 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 #================================================= @@ -47,115 +16,66 @@ ynh_abort_if_errors #================================================= 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" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -if [ -z "$use_beolingus" ]; then - use_beolingus=0 - ynh_app_setting_set --app=$app --key=use_beolingus --value=$use_beolingus +if [ -z "${use_beolingus:-}" ]; then + use_beolingus=0 + ynh_app_setting_set --app="$app" --key=use_beolingus --value=$use_beolingus fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" - - download_data -fi +download_data #================================================= -# UPGRADE DEPENDENCIES +# SPECIFIC SETUP #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - +# ADD A CONFIGURATION #================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# COMPILE FASTTEXT -#================================================= - -compile_fasttext - -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression --message="Adding a configuration file..." add_languagetool_config #================================================= -# SECURE FILES AND DIRECTORIES +# COMPILE FASTTEXT #================================================= - -# Set permissions on app files -set_permissions +if [ "$use_fasttext" -eq 1 ]; then + ynh_script_progression --message="Compiling fasttext..." --weight=15 + compile_fasttext +fi #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +yunohost service add "$app" --description="Multilingual grammar, style, and spell checker" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Multilingual grammar, style, and spell checker" --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="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..17ddb10 --- /dev/null +++ b/tests.toml @@ -0,0 +1,14 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + args.use_ngram = false + args.use_compressed_fasttext = true + + # ------------ + # Tests to run + # ------------ + + test_upgrade_from.81d1f5dc1a42305d8cf3a6264176838d0164bfdb.name = "5.7~ynh1"