2023-09-24 20:10:09 -06:00
|
|
|
#!/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.
|
2025-01-01 10:59:28 -07:00
|
|
|
sudo -iu postgres psql -c '\l' | grep wrolpi || (
|
|
|
|
|
sudo -iu postgres createuser -s wrolpi # superuser so maps can be imported
|
|
|
|
|
sudo -iu postgres psql -c "alter user postgres password 'wrolpi'"
|
|
|
|
|
sudo -iu postgres psql -c "alter user wrolpi password 'wrolpi'"
|
|
|
|
|
sudo -iu postgres createdb -E UTF8 -O wrolpi wrolpi
|
2023-09-24 20:10:09 -06:00
|
|
|
echo "Created wrolpi database"
|
|
|
|
|
)
|
2025-01-01 10:59:28 -07:00
|
|
|
sudo -iu wrolpi /bin/bash -c 'cd /opt/wrolpi && /opt/wrolpi/venv/bin/python3 main.py db upgrade'
|