mirror of
https://github.com/YunoHost-Apps/languagetool_ynh.git
synced 2024-09-03 19:35:58 +02:00
Add Beolingus support
This commit is contained in:
parent
de5ef9b11c
commit
a271f12f9d
11 changed files with 83 additions and 55 deletions
|
@ -7,6 +7,8 @@
|
|||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
use_ngram=0 (USE_NGRAM)
|
||||
use_word2vec=1 (USE_WORD2VEC)
|
||||
use_beolingus=1 (USE_BEOLINGUS)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
|
|
7
conf/beolingus.src
Normal file
7
conf/beolingus.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
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
|
|
@ -2,4 +2,5 @@ __LANGUAGE_MODEL_CONFIG_LINE__
|
|||
__WORD2VEC_MODEL_CONFIG_LINE__
|
||||
__FASTTEXT_MODEL_CONFIG_LINE__
|
||||
__FASTTEXT_BINARY_CONFIG_LINE__
|
||||
__BEOLINGUS_FILE_CONFIG_LINE__
|
||||
__GRAMMALECTE_SERVER_CONFIG_LINE__
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
|
@ -92,6 +92,19 @@
|
|||
},
|
||||
"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",
|
||||
|
|
|
@ -41,6 +41,10 @@ function download_data {
|
|||
fi
|
||||
ynh_setup_source --dest_dir="$final_path/fasttext" --source_id="fasttext"
|
||||
fi
|
||||
|
||||
if [ $use_beolingus -eq 1 ]; then
|
||||
ynh_setup_source --dest_dir="$data_path/beolingus" --source_id="beolingus"
|
||||
fi
|
||||
}
|
||||
|
||||
function add_languagetool_config {
|
||||
|
@ -68,6 +72,12 @@ function add_languagetool_config {
|
|||
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 [ ! -z $grammalecte_server ]; then
|
||||
grammalecte_server_config_line="grammalecteServer=$grammalecte_server/gc_text/fr"
|
||||
else
|
||||
|
@ -82,9 +92,9 @@ function compile_fasttext {
|
|||
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
|
||||
chown -R $app:$app $final_path/fasttext
|
||||
sudo -u $app make
|
||||
chown -R root:root $final_path/fasttext
|
||||
popd || ynh_die
|
||||
fi
|
||||
}
|
||||
|
@ -96,6 +106,23 @@ function set_permissions {
|
|||
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_word2vec=$(ynh_app_setting_get --app=$app --key=use_word2vec)
|
||||
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)
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_setup() {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
|
|
@ -26,8 +26,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
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)
|
||||
load_installation_settings
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
|
@ -36,7 +35,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
|
|||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
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"
|
||||
|
||||
|
@ -51,8 +50,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
if [ "$old_domain" != "$new_domain" ]; then
|
||||
change_domain=1
|
||||
fi
|
||||
change_path=0
|
||||
|
@ -74,8 +72,7 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
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
|
||||
|
|
|
@ -31,6 +31,7 @@ use_untested_ngram=$YNH_APP_ARG_USE_UNTESTED_NGRAM
|
|||
use_word2vec=$YNH_APP_ARG_USE_WORD2VEC
|
||||
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
|
||||
|
||||
|
@ -59,6 +60,7 @@ ynh_app_setting_set --app=$app --key=use_untested_ngram --value=$use_untested_ng
|
|||
ynh_app_setting_set --app=$app --key=use_word2vec --value=$use_word2vec
|
||||
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
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -14,11 +14,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
||||
load_installation_settings
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -27,8 +23,7 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
|||
#=================================================
|
||||
|
||||
# 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
|
||||
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
|
||||
fi
|
||||
|
|
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_setup() {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -25,30 +25,19 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
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_word2vec=$(ynh_app_setting_get --app=$app --key=use_word2vec)
|
||||
use_fasttext=$(ynh_app_setting_get --app=$app --key=use_fasttext)
|
||||
use_compressed_fasttext=$(ynh_app_setting_get --app=$app --key=use_compressed_fasttext)
|
||||
grammalecte_server=$(ynh_app_setting_get --app=$app --key=grammalecte_server)
|
||||
load_installation_settings
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
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 "
|
||||
test ! -d $data_path \
|
||||
|| ynh_die --message="There is already a directory: $data_path "
|
||||
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 "
|
||||
test ! -d $data_path ||
|
||||
ynh_die --message="There is already a directory: $data_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
|
|
@ -14,19 +14,15 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
load_installation_settings
|
||||
|
||||
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_word2vec=$(ynh_app_setting_get --app=$app --key=use_word2vec)
|
||||
use_fasttext=$(ynh_app_setting_get --app=$app --key=use_fasttext)
|
||||
use_compressed_fasttext=$(ynh_app_setting_get --app=$app --key=use_compressed_fasttext)
|
||||
grammalecte_server=$(ynh_app_setting_get --app=$app --key=grammalecte_server)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
if [ -z "$use_beolingus" ]; then
|
||||
use_beolingus=0
|
||||
ynh_app_setting_set --app=$app --key=use_beolingus --value=$use_beolingus
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -41,7 +37,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_setup() {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
|
@ -61,8 +57,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue