diff --git a/README.md b/README.md index 0086c366..5a6686ca 100644 --- a/README.md +++ b/README.md @@ -658,9 +658,10 @@ Move the `environment=` values of that config into `/etc/default/webvirtcloud` ( - a literal `SECRET_KEY = "..."` (older installers wrote it there): put the value into `data/secret_key` instead (`mkdir -p data` first if there is no `data/`). With no key, `migrate` in step 3 stops with "The SECRET_KEY setting must not be empty" and every page fails; with another key, every user is signed out; - `SHOW_PROFILE_EDIT_PASSWORD`: keep it for this one `migrate` if you have it (migration `accounts.0008` reads it), then delete it. -3. Install, migrate, and fix ownership and modes (`nginx:nginx` instead of `www-data:www-data` on RHEL / openSUSE). With LDAP, also run `venv/bin/pip3 install -U -r conf/requirements-ldap.txt` (headers: [LDAP](#ldap)): +3. Load `/etc/default/webvirtcloud` if you use it (its database is the one to migrate), install, migrate, and fix ownership and modes (`nginx:nginx` instead of `www-data:www-data` on RHEL / openSUSE). With LDAP, also run `venv/bin/pip3 install -U -r conf/requirements-ldap.txt` (headers: [LDAP](#ldap)): ```bash + { [ ! -f /etc/default/webvirtcloud ] || { set -a; . /etc/default/webvirtcloud; set +a; }; } && venv/bin/pip3 install -U -r conf/requirements.txt && { ! tar -tf "$b/local-migrations.tar" | grep -qx accounts/migrations/0006_alter_userattributes_id_alter_userinstance_id_and_more.py || venv/bin/python3 manage.py migrate accounts 0005 --fake; } && @@ -730,6 +731,7 @@ git checkout "$(cat "$b/commit")" && venv/bin/python3 -c "import os,sqlite3,sys; [os.remove(p) for p in ('db.sqlite3-journal','db.sqlite3-wal','db.sqlite3-shm') if os.path.exists(p)]; sqlite3.connect(sys.argv[1]).backup(sqlite3.connect('db.sqlite3'))" "$b/db.sqlite3" && cp "$b/settings.py" webvirtcloud/settings.py && { [ ! -f "$b/webvirtcloud.conf" ] || cp "$b/webvirtcloud.conf" /etc/nginx/conf.d/webvirtcloud.conf; } && +{ [ ! -f "$b/webvirtcloud" ] || { set -a; . "$b/webvirtcloud"; set +a; }; } && venv/bin/pip3 install -r conf/requirements.txt && venv/bin/python3 manage.py migrate && venv/bin/python3 manage.py collectstatic --noinput && diff --git a/webvirtcloud.sh b/webvirtcloud.sh index 60cb1402..34d15d94 100755 --- a/webvirtcloud.sh +++ b/webvirtcloud.sh @@ -306,6 +306,15 @@ install_webvirtcloud () { chown -R "$nginx_group":"$nginx_group" "$APP_PATH" + # the services' environment (PostgreSQL, SECRET_KEY): migrate must reach their database + if [ -f /etc/default/webvirtcloud ]; then + # -v traces every command: the file's passwords stay out of that trace + case $- in *x*) trace=true; set +x ;; *) trace=false ;; esac + # shellcheck source=/dev/null + set -a; . /etc/default/webvirtcloud; set +a + if $trace; then set -x; fi + fi + echo "* Django Migrate." log "$PYTHON $APP_PATH/manage.py migrate" || { echo "manage.py migrate failed: see /var/log/webvirtcloud-install.log." >&2; exit 1; }