главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/update.sh
diff options
context:
space:
mode:
authorIvan Davydov <lotigara@lotigara.ru>2025-03-23 16:07:46 +0300
committerIvan Davydov <lotigara@lotigara.ru>2025-03-28 10:41:24 +0300
commita0f5891f7ebaef61c8ea362b4540d027f633849d (patch)
tree97571e7e46bf06af8d2f005ffbc54ca7a4aeb79d /update.sh
parent553e884a45de6f67fb842dd281c662db1000cce3 (diff)
Big refactorHEADmain
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.
Diffstat (limited to 'update.sh')
-rwxr-xr-x[-rw-r--r--]update.sh45
1 files changed, 39 insertions, 6 deletions
diff --git a/update.sh b/update.sh
index 779c393..9afde02 100644..100755
--- 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 <<EOF
+ cd $LT_DIR
+ git pull
+ . venv/bin/activate
+ pip install -U gunicorn
+ pip install $LT_DIR --no-cache-dir -U
+ if [ "$1" = 'update-models' ]; then
+ scripts/install_models.py
+ fi
+EOF
+
+echo 'Re-loading nginx configuration...'
+systemctl restart nginx
+echo 'Re-loading systemd configuration...'
+systemctl daemon-reload
+echo 'Starting LibreTranslate...'
+systemctl start libretranslate