главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/update.sh
blob: 9afde02db4100fc77d769d57d7464d2ef5deab06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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