#!/bin/sh if [ -f .env ]; then set -a . ./.env set +a else . ./.env.example fi # --- echo 'Updating package index...' apt-get update echo 'Installing dependencies...' # Install Python, PyICU dependencies (https://community.libretranslate.com/t/pyicu-fails-to-install-on-ubuntu-20-04/23), Nginx and optionally Certbot with Nginx plugin apt-get install -y python3 python3-virtualenv python-is-python3 python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools \ libicu-dev python3-icu pkg-config \ nginx # --- echo 'Creating LibreTranslate user...' useradd --system -m --home-dir $LT_DIR $LT_USER cp $PWD/.env $LT_DIR/.env && chown -R $LT_USER $LT_DIR echo 'Downloading and installing LibreTranslate...' su -ls /bin/sh $LT_USER < libretranslate.service cp -v libretranslate.service /etc/systemd/system/ systemctl enable --now libretranslate echo 'Configuring Nginx site...' sed -e "{s|\$LT_DIR|$LT_DIR|;s|\$LT_DOMAIN|$LT_DOMAIN|}" nginx.example > nginx cp -v nginx /etc/nginx/sites-available/libretranslate ln -sv /etc/nginx/sites-available/libretranslate /etc/nginx/sites-enabled/libretranslate nginx -t && systemctl restart nginx # --- echo "Done! Now you can visit the http://$LT_DOMAIN website. You can use the ./get-cert.sh script to get an SSL certificate."