dockersetup: move superuser account creation to the end

If we move the superuser account creation to the end, it's practical to
Ctrl+C it in case you already have a superuser in the data that got
imported.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-01-22 15:47:16 +13:00
parent b99143d2e3
commit 604330f41a

View File

@ -541,13 +541,6 @@ if not updatemode:
finally: finally:
os.remove(sqlscriptfile) os.remove(sqlscriptfile)
## For a fresh database, create an admin account
print("Creating database superuser. Input user name, email, and password when prompted.")
return_code = subprocess.call("docker-compose run --rm layersapp /opt/layerindex/manage.py createsuperuser", shell=True)
if return_code != 0:
print("Creating superuser failed")
sys.exit(1)
## Set the volume permissions using debian:stretch since we recently fetched it ## Set the volume permissions using debian:stretch since we recently fetched it
return_code = subprocess.call("docker run --rm -v layerindexweb_layersmeta:/opt/workdir debian:stretch chown 500 /opt/workdir && \ return_code = subprocess.call("docker run --rm -v layerindexweb_layersmeta:/opt/workdir debian:stretch chown 500 /opt/workdir && \
docker run --rm -v layerindexweb_layersstatic:/usr/share/nginx/html debian:stretch chown 500 /usr/share/nginx/html", shell=True) docker run --rm -v layerindexweb_layersstatic:/usr/share/nginx/html debian:stretch chown 500 /usr/share/nginx/html", shell=True)
@ -561,6 +554,15 @@ if return_code != 0:
print("Collecting static files failed") print("Collecting static files failed")
sys.exit(1) sys.exit(1)
if not updatemode:
## For a fresh database, create an admin account
print("Creating database superuser. Input user name, email, and password when prompted.")
return_code = subprocess.call("docker-compose run --rm layersapp /opt/layerindex/manage.py createsuperuser", shell=True)
if return_code != 0:
print("Creating superuser failed")
sys.exit(1)
if updatemode: if updatemode:
print("Update complete") print("Update complete")
else: else: