-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
migrate-docker
executable file
·69 lines (53 loc) · 1.77 KB
/
migrate-docker
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
# shellcheck disable=SC1091
. /etc/weblate-bootstrap
# Set path to include script directory
PATH="$(dirname "$(readlink -f "$0")"):$PATH"
export PATH
# Use same variables as in other scripts even though these are not configurable here
WEBLATE_USERNAME=weblate
USERNAME=weblate
WEBLATE_HOME=$(getent passwd "$USERNAME" | cut -d: -f 6)
WEBLATE_ENV="$WEBLATE_HOME/weblate-env"
WEBLATE_DOCKER="$WEBLATE_HOME/weblate"
# Install docker
install-docker
# Stop services, wait for empty queue
systemctl stop uwsgi
while sudo -u "$WEBLATE_USERNAME" "$WEBLATE_ENV/bin/weblate" celery_queues | grep ': [^0]' ; do
sleep 1
done
systemctl stop celery-weblate
systemctl disable celery-weblate
systemctl stop redis
# Prepare Docker environment
install-weblate-docker "$@" --migrate
# Dump PostgreSQL and load it to Docker
# shellcheck disable=SC2024
sudo -u "postgres" pg_dump --no-privileges --no-owner --clean --if-exists weblate > "$WEBLATE_HOME/weblate.sql"
systemctl stop postgresql
cd "$WEBLATE_DOCKER"
docker compose up -d database --wait
sleep 60
docker compose exec -T database psql --username weblate --dbname weblate < "$WEBLATE_HOME/weblate.sql"
# Move redis data
cp /var/lib/redis/dump.rdb "$WEBLATE_HOME/redis"
chown -R 999:1000 "$WEBLATE_HOME/redis"
# Filesystem data is already in correct place
chown -R 1000:1000 "$WEBLATE_HOME/data"
# Cleanup system packages
apt-get purge -y \
redis-server \
uwsgi \
postgresql
# Start Weblate
sudo -u weblate docker compose up -d --wait
# Show logs
sudo -u weblate docker compose logs
# Track deploy to Sentry
if [ -n "$WEBLATE_SENTRY_TOKEN" ] ; then
sudo -u weblate docker compose exec --user weblate weblate weblate sentry_deploy
fi
# Check
sudo -u weblate docker compose exec --user weblate weblate weblate check --deploy