diff options
Diffstat (limited to 'update.sh')
-rwxr-xr-x[-rw-r--r--] | update.sh | 45 |
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 |