Add languagetool (ct)

This commit is contained in:
push-app-to-main[bot]
2026-01-30 16:22:38 +00:00
parent 0fc4e6ed10
commit cf9f18b822
3 changed files with 220 additions and 0 deletions

67
ct/languagetool.sh Normal file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://languagetool.org/
APP="LanguageTool"
var_tags="${var_tags:-spellcheck}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-8}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/LanguageTool ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://languagetool.org/download/ | grep -oP 'LanguageTool-\K[0-9]+\.[0-9]+(\.[0-9]+)?(?=\.zip)' | sort -V | tail -n1)
if [[ "${RELEASE}" != "$(cat ~/.languagetool 2>/dev/null)" ]] || [[ ! -f ~/.languagetool ]]; then
msg_info "Stopping LanguageTool"
systemctl stop language-tool
msg_ok "Stopped LanguageTool"
msg_info "Creating Backup"
cp /opt/LanguageTool/server.properties /opt/server.properties
msg_ok "Backup Created"
msg_info "Updating LanguageTool"
rm -rf /opt/LanguageTool
download_file "https://languagetool.org/download/LanguageTool-stable.zip" /tmp/LanguageTool-stable.zip
unzip -q /tmp/LanguageTool-stable.zip -d /opt
mv /opt/LanguageTool-*/ /opt/LanguageTool/
mv /opt/server.properties /opt/LanguageTool/server.properties
echo "${RELEASE}" >~/.languagetool
msg_ok "Updated LanguageTool"
msg_info "Starting LanguageTool"
systemctl start language-tool
msg_ok "Started LanguageTool"
msg_ok "Updated successfuly!"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
start
build_container
description
msg_ok "Completed successfully!"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8081/v2${CL}"

View File

@@ -0,0 +1,44 @@
{
"name": "LanguageTool",
"slug": "languagetool",
"categories": [
0
],
"date_created": "2025-12-10",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 8081,
"documentation": "https://dev.languagetool.org/",
"config_path": "/opt/LanguageTool/server.properties",
"website": "https://languagetool.org/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/languagetool.webp",
"description": "LanguageTool is an Open Source proofreading software for English, Spanish, French, German, Portuguese, Polish, Dutch, and more than 20 other languages. It finds many errors that a simple spell checker cannot detect.",
"install_methods": [
{
"type": "default",
"script": "ct/languagetool.sh",
"resources": {
"cpu": 2,
"ram": 4096,
"hdd": 8,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "API is available at `http://<LXC_IP>:8081/v2`.",
"type": "info"
},
{
"text": "Application doesn't come with n-gram data. If you wish to use that feature, please look at `https://dev.languagetool.org/finding-errors-using-n-gram-data.html`.",
"type": "info"
}
]
}

View File

@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://languagetool.org/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing dependencies"
$STD apt install -y fasttext
msg_ok "Installed dependencies"
JAVA_VERSION="21" setup_java
msg_info "Setting up LanguageTool"
RELEASE=$(curl -fsSL https://languagetool.org/download/ | grep -oP 'LanguageTool-\K[0-9]+\.[0-9]+(\.[0-9]+)?(?=\.zip)' | sort -V | tail -n1)
download_file "https://languagetool.org/download/LanguageTool-stable.zip" /tmp/LanguageTool-stable.zip
unzip -q /tmp/LanguageTool-stable.zip -d /opt
mv /opt/LanguageTool-*/ /opt/LanguageTool/
download_file "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin" /opt/lid.176.bin
msg_ok "Setup LanguageTool"
ngram_dir=""
lang_code=""
max_attempts=3
attempt=0
while [[ $attempt -lt $max_attempts ]]; do
read -r -p "${TAB3}Enter language code (en, de, es, fr, nl) to download ngrams or press ENTER to skip: " lang_code
if [[ -z "$lang_code" ]]; then
break
fi
if [[ "$lang_code" =~ [[:space:]] ]]; then
((attempt++))
remaining=$((max_attempts - attempt))
if [[ $remaining -gt 0 ]]; then
msg_error "Please enter only ONE language code. You have $remaining attempt(s) remaining."
else
msg_error "Maximum attempts reached. Continuing without ngrams."
lang_code=""
fi
continue
fi
break
done
if [[ -n "$lang_code" ]]; then
if [[ "$lang_code" =~ ^(en|de|es|fr|nl)$ ]]; then
msg_info "Searching for $lang_code ngrams..."
filename=$(curl -fsSL https://languagetool.org/download/ngram-data/ | grep -oP "ngrams-${lang_code}-[0-9]+\.zip" | sort -uV | tail -n1)
if [[ -n "$filename" ]]; then
msg_info "Downloading $filename"
download_file "https://languagetool.org/download/ngram-data/${filename}" "/tmp/${filename}"
mkdir -p /opt/ngrams
msg_info "Extracting $lang_code ngrams to /opt/ngrams"
unzip -q "/tmp/${filename}" -d /opt/ngrams
rm "/tmp/${filename}"
ngram_dir="/opt/ngrams"
msg_ok "Installed $lang_code ngrams"
else
msg_info "No ngram file found for ${lang_code}"
fi
else
msg_error "Invalid language code: $lang_code"
fi
fi
cat <<EOF >/opt/LanguageTool/server.properties
fasttextModel=/opt/lid.176.bin
fasttextBinary=/usr/bin/fasttext
EOF
if [[ -n "$ngram_dir" ]]; then
echo "languageModel=/opt/ngrams" >> /opt/LanguageTool/server.properties
fi
echo "${RELEASE}" >~/.languagetool
msg_ok "Setup LanguageTool"
msg_info "Creating Service"
cat <<'EOF' >/etc/systemd/system/language-tool.service
[Unit]
Description=LanguageTool Service
After=network.target
[Service]
WorkingDirectory=/opt/LanguageTool
ExecStart=java -cp languagetool-server.jar org.languagetool.server.HTTPServer --config server.properties --public --allow-origin "*"
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now language-tool
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc