From a0f5891f7ebaef61c8ea362b4540d027f633849d Mon Sep 17 00:00:00 2001 From: Ivan Davydov Date: Sun, 23 Mar 2025 16:07:46 +0300 Subject: Big refactor TL;DR: this commit makes README.md more simple and makes scripts more complex. This commit makes scripts look (and behave) like scripts. That is, they now contain shebangs, `echo` lines to allow user to watch the installation process. The latter is now more configurable: user can customize the directory, where LibreTranslate will be installed, username, which will be used to run LibreTranslate and the domain name configuration is now contained in the .env file, which used for all other settings. --- update.sh | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) mode change 100644 => 100755 update.sh (limited to 'update.sh') diff --git a/update.sh b/update.sh old mode 100644 new mode 100755 index 779c393..9afde02 --- a/update.sh +++ b/update.sh @@ -1,6 +1,39 @@ -cd ~/LibreTranslate-init -git pull -rm -rf ~/LibreTranslate/env -virtualenv ~/LibreTranslate/env -~/LibreTranslate/env/bin/pip install ~/LibreTranslate/ --no-cache-dir -~/LibreTranslate/env/bin/libretranslate --update-models +#!/bin/sh + +if [ -f .env ]; then + . ./.env +else + . ./.env.example +fi + +echo 'Stopping LibreTranslate...' +systemctl stop libretranslate + +echo 'Updating the LibreTranslate systemd service according to the .env file...' +sed -e "{s|\$LT_DIR|$LT_DIR|;s|\$LT_USER|$LT_USER|}" libretranslate.service.example > libretranslate.service +cp -v libretranslate.service /etc/systemd/system/ + +echo 'Updating the nginx site according to the .env file...' +sed -e "{s|\$LT_DIR|$LT_DIR|;s|\$LT_DOMAIN|$LT_DOMAIN|}" nginx.example > nginx +cp -v nginx /etc/nginx/sites-available/libretranslate + +cp $PWD/.env $LT_DIR/.env && chown -R $LT_USER $LT_DIR + +echo 'Updating LibreTranslate...' +su -ls /bin/sh $LT_USER <