#!/usr/bin/env bash
# Repo
curl -sS https://apertium.projectjj.com/apt/install-nightly.sh | sudo bash
# Install
sudo apt install libboost-dev libgoogle-perftools-dev libicu-dev cmake subversion build-essential pkg-config gawk libxml2 libxml2-dev libxml2-utils xsltproc flex automake libtool libpcre3-dev zlib1g-dev locales build-essential automake subversion git pkg-config libtool apertium-all-dev
# Extras
sudo apt install apertium-eng apertium-spa apertium-en-es apertium-es-* apertium-all-dev
# Some deps
sudo apt install build-essential python3-dev python3-pip zlib1g-dev subversion python3-tornado python3-fasttext python3-commentjson python3-chardet python3-chardet python3-lxml python3-flake8 python3-flake8-quotes
## System User
sudo mkdir /var/opt/apertium
sudo useradd -d /var/opt/apertium -r -s /bin/false apertium
### Language Identification
sudo curl "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin" -o "/var/opt/apertium/lid.176.bin"
sudo curl "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftz" -o "/var/opt/apertium/lid.176.ftz"
# Clone the actual repo ya dum dum
sudo git clone https://github.com/apertium/apertium-apy /var/opt/apertium/apertium-apy
# nearly forgot that
sudo chown -R apertium:apertium /var/opt/apertium
## System Service
sudo chown --reference=/var/log /var/log/apy;
sudo bash -c "echo > /etc/systemd/system/apertium-apy.service"
sudo bash -c "cat >> /etc/systemd/system/apertium-apy.service" << EOL
[Unit]
Description=Translation server and API for Apertium
Documentation=http://wiki.apertium.org/wiki/Apertium-apy
After=network.target
[Service]
User=apertium
Group=apertium
WorkingDirectory=/var/opt/apertium
# Note how its apy not servlet bc they changed it sometime in the past
# and didnt update the goddamn documentation nor the apt packages!
ExecStart=/usr/bin/python3 /var/opt/apertium/apertium-apy/apy.py /usr/share/apertium/modes --fasttext-model /var/opt/apertium/lid.176.bin
Restart=always
WatchdogSec=10s
PrivateTmp=true
# Journaling its missing on the deault
StandardOutput=journal
StandardError=/var/log/apy/apy-error.log
[Install]
WantedBy=multi-user.target
EOL
### Load service and display
sudo systemctl daemon-reload
sudo systemctl enable apertium-apy
sudo systemctl start apertium-apy
sudo systemctl status apertium-apy
sudo journalctl -xef -u apertium-apy
#!/bin/bash
if [[ `whoami` != root ]]
then
echo "You must run this Apertium install script as root, or via sudo!"
exit -1
fi
CADENCE=nightly
if [[ -x "$(which curl)" ]]; then
GET="curl --insecure -sS"
elif [[ -x "$(which wget)" ]]; then
GET="wget --no-check-certificate -nv -O -"
else
echo "Neither curl nor wget found - need one of them!"
exit -1
fi
echo "Cleaning up old install, if any..."
rm -fv /etc/apt/trusted.gpg.d/apertium* /etc/apt/preferences.d/apertium* /etc/apt/sources.list.d/apertium*
echo "Determining Debian/Ubuntu codename..."
P=`apt-cache policy`
P="$P "`lsb_release -c`"/dummy"
P="$P "`grep CODENAME /etc/lsb-release`"/dummy"
DISTRO="$1"
for D in sid buster bullseye bookworm bionic focal jammy kinetic mantic noble kali-rolling
do
if [[ $P == *$D/* ]]
then
DISTRO=$D
echo "Found evidence of $D..."
fi
done
if [[ $DISTRO == "kali-rolling" ]]
then
DISTRO=bullseye
echo "Assuming kali-rolling = $DISTRO"
fi
if [[ -z "$DISTRO" ]]
then
echo "No supported Debian or Ubuntu derivative detected - bailing out..."
exit -1
fi
echo "Settling for $DISTRO - enabling the Apertium $CADENCE repo..."
echo "Installing Apertium GnuPG key to /etc/apt/trusted.gpg.d/apertium.gpg"
$GET https://apertium.projectjj.com/apt/apertium-packaging.public.gpg >/etc/apt/trusted.gpg.d/apertium.gpg
echo "Installing package override to /etc/apt/preferences.d/apertium.pref"
$GET https://apertium.projectjj.com/apt/apertium.pref >/etc/apt/preferences.d/apertium.pref
echo "Creating /etc/apt/sources.list.d/apertium.list"
echo "deb http://apertium.projectjj.com/apt/$CADENCE $DISTRO main" > /etc/apt/sources.list.d/apertium.list
echo "Running apt-get update..."
apt-get -qy update >/dev/null 2>&1
echo "All done - enjoy the packages! If you just want all core tools, do: sudo apt-get install apertium-all-dev"