Combining install scripts into a new repair script. Removing create_db script in favor of repair script.

This commit is contained in:
Roland 2023-09-24 20:10:09 -06:00
parent b817534c37
commit 6e0f9a999c
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
57 changed files with 785 additions and 724 deletions

21
scripts/initialize_api_db.sh Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Creates the wrolpi database user and database if they don't exist.
# It is always safe to run this script.
# Re-execute this script if it wasn't called with sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
set -x
# Create WROLPi API database.
sudo -u postgres psql -c '\l' | grep wrolpi || (
sudo -u postgres createuser -s wrolpi # superuser so maps can be imported
sudo -u postgres psql -c "alter user postgres password 'wrolpi'"
sudo -u postgres psql -c "alter user wrolpi password 'wrolpi'"
sudo -u postgres createdb -E UTF8 -O wrolpi wrolpi
echo "Created wrolpi database"
)
sudo -u wrolpi /bin/bash -c 'cd /opt/wrolpi && /opt/wrolpi/venv/bin/python3 main.py db upgrade'