mirror of
https://github.com/joglomedia/LEMPer.git
synced 2026-04-03 11:18:21 +00:00
Update Postgres installer
This commit is contained in:
@@ -31,9 +31,9 @@ function add_postgres_repo() {
|
||||
if [[ ! -f "/etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list" ]]; then
|
||||
echo "Adding PostgreSQL repository..."
|
||||
|
||||
run touch "/etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list" && \
|
||||
run bash -c "echo 'deb [ signed-by=/usr/share/keyrings/postgres-${RELEASE_NAME}.gpg ] http://apt.postgresql.org/pub/repos/apt ${RELEASE_NAME}-pgdg main' > /etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list" && \
|
||||
run bash -c "curl -fsSL https://www.postgresql.org/media/keys/${POSTGRES_REPO_KEY}.asc | gpg --dearmor --yes -o /usr/share/keyrings/postgres-${RELEASE_NAME}.gpg" && \
|
||||
run touch "/etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list" && \
|
||||
run bash -c "echo 'deb [signed-by=/usr/share/keyrings/postgres-${RELEASE_NAME}.gpg] http://apt.postgresql.org/pub/repos/apt ${RELEASE_NAME}-pgdg main' > /etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list" && \
|
||||
run apt-get update -q -y
|
||||
else
|
||||
info "PostgreSQL ${POSTGRES_VERSION} repository already exists."
|
||||
@@ -63,10 +63,9 @@ function init_postgres_install() {
|
||||
done
|
||||
fi
|
||||
|
||||
#export POSTGRES_SUPERUSER=${POSTGRES_SUPERUSER:-"postgres"}
|
||||
POSTGRES_SUPERUSER=${POSTGRES_SUPERUSER:-"postgres"}
|
||||
POSTGRES_DB_USER=${POSTGRES_DB_USER:-"${LEMPER_USERNAME}"}
|
||||
POSTGRES_DB_PASS=${POSTGRES_DB_PASS:-$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)}
|
||||
export POSTGRES_SUPERUSER=${POSTGRES_SUPERUSER:-"postgres"}
|
||||
export POSTGRES_DB_USER=${POSTGRES_DB_USER:-"${LEMPER_USERNAME}"}
|
||||
export POSTGRES_DB_PASS=${POSTGRES_DB_PASS:-$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)}
|
||||
|
||||
local POSTGRES_VERSION=${POSTGRES_VERSION:-"15"}
|
||||
local POSTGRES_TEST_DB="${POSTGRES_DB_USER}db"
|
||||
@@ -170,7 +169,7 @@ echo "[PostgreSQL Installation]"
|
||||
|
||||
# Start running things from a call at the end so if this script is executed
|
||||
# after a partial download it doesn't do anything.
|
||||
if [[ -n $(command -v postgres) && "${FORCE_INSTALL}" != true ]]; then
|
||||
if [[ -n $(command -v psql) && "${FORCE_INSTALL}" != true ]]; then
|
||||
info "PostgreSQL server already exists, installation skipped."
|
||||
else
|
||||
init_postgres_install "$@"
|
||||
|
||||
@@ -50,11 +50,6 @@ function init_postgres_removal() {
|
||||
|
||||
# Remove config.
|
||||
postgres_remove_config
|
||||
|
||||
# Remove repository.
|
||||
if [[ "${FORCE_REMOVE}" == true ]]; then
|
||||
run rm -f "/etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list"
|
||||
fi
|
||||
else
|
||||
echo "No installed PostgreSQL ${POSTGRES_VERSION} or MySQL packages found."
|
||||
echo "Possibly installed from source? Remove it manually!"
|
||||
@@ -98,6 +93,10 @@ function postgres_remove_config() {
|
||||
[ -d "${PGDATA}" ] && run rm -fr "${PGDATA}"
|
||||
[ -d "/etc/postgresql/${POSTGRES_VERSION}" ] && run rm -fr "/etc/postgresql/${POSTGRES_VERSION}"
|
||||
|
||||
# Remove repository.
|
||||
run rm -f "/etc/apt/sources.list.d/postgres-${RELEASE_NAME}.list"
|
||||
run rm -f "/usr/share/keyrings/postgres-${RELEASE_NAME}.gpg"
|
||||
|
||||
echo "All database and configuration files deleted permanently."
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user