linkwarden: removed unnecessary build step, fixed deploy command postgresql: locked major version, bumpt it from 17 to 18, updated config for compatibility, added sleep to config to make sure Postgres is up aptcacherng: skips overwriting existing service symlink
37 lines
1.9 KiB
Bash
37 lines
1.9 KiB
Bash
#!/bin/bash
|
|
read -p "Enter your e-mail for pgAdmin login: " PostgressAdminMail
|
|
read -p "Enter new password for pgAdmin and postgresql database admin: " -s NewPostgressPassword
|
|
echo
|
|
echo "Please wait..."
|
|
sleep 30
|
|
|
|
#Configure Postgresql
|
|
su postgres -c "psql -c \"alter user postgres with password '$NewPostgressPassword';\""
|
|
|
|
#Configure pgAdmin
|
|
##Create pgadmin db for storing pgAdmin config
|
|
PGADMIN_DB_PASSWORD=$(dd bs=20 count=1 if=/dev/urandom | base64 | tr +/ _.)
|
|
su postgres -c "psql -c \"CREATE ROLE pgadmin WITH LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOREPLICATION NOBYPASSRLS CONNECTION LIMIT 25 PASSWORD '$PGADMIN_DB_PASSWORD';\""
|
|
su postgres -c "psql -c \"CREATE DATABASE pgadmin WITH OWNER = pgadmin ENCODING = 'UTF8' LOCALE_PROVIDER = 'libc' CONNECTION LIMIT = -1 IS_TEMPLATE = False;\""
|
|
sed -i "s/DBPassword/$PGADMIN_DB_PASSWORD/" /usr/pgadmin4/web/config_local.py
|
|
|
|
##Setup the pgAdmin base
|
|
export PGADMIN_SETUP_EMAIL=$PostgressAdminMail
|
|
export PGADMIN_SETUP_PASSWORD=$NewPostgressPassword
|
|
su -pc "/usr/pgadmin4/venv/bin/python3 /usr/pgadmin4/web/setup.py setup-db" pgadmin
|
|
systemctl restart pgadmin
|
|
|
|
## add localhost postges server as connection is pgAdmin
|
|
sed -i "s/Password/$NewPostgressPassword/" /opt/Setup/Configs/pgpassfile
|
|
mv /opt/Setup/Configs/pgpassfile /var/lib/pgadmin/storage/shared/pgpassfile
|
|
chown pgadmin: /var/lib/pgadmin/storage/shared/pgpassfile
|
|
chmod 600 /var/lib/pgadmin/storage/shared/pgpassfile
|
|
/usr/pgadmin4/venv/bin/python3 /usr/pgadmin4/web/setup.py load-servers /opt/Setup/Configs/pgadmin-server-import.json --user $PostgressAdminMail
|
|
|
|
## Set user preferences (i.e. set the theme to system)
|
|
/usr/pgadmin4/venv/bin/python3 /usr/pgadmin4/web/setup.py set-prefs $PostgressAdminMail --input-file /opt/Setup/Configs/pgadmin-user-preferences.json
|
|
|
|
##Clean-up
|
|
rm /root/ReadMe /opt/Setup/Configs/pgadmin-server-import.json /opt/Setup/Configs/pgadmin-user-preferences.json
|
|
|