mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(install): migrate runs with /etc/default/webvirtcloud loaded
The services read their environment from /etc/default/webvirtcloud, but a re-run of the installer and the README's update and rollback steps ran manage.py migrate without it: with WEBVIRTCLOUD_DB_HOST set there, the migrations went to the fallback sqlite file and PostgreSQL kept the old schema. All three now load the file first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
0c028ef107
commit
bba4f7908e
2 changed files with 12 additions and 1 deletions
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue