Compare commits

...

2 Commits

Author SHA1 Message Date
CanbiZ
7ba7ea85bc Merge PostgreSQL to tools.func Installer 2025-05-27 14:10:58 +02:00
CanbiZ
76016cefe9 Update tools.func 2025-05-27 14:00:06 +02:00
8 changed files with 47 additions and 41 deletions

View File

@ -25,10 +25,9 @@ $STD apt-get install -y \
msg_ok "Installed Dependencies"
NODE_VERSION="22" NODE_MODULE="pnpm@latest" install_node_and_modules
PG_VERSION="16" install_postgresql
PG_VERSION="16" PG_MODULES="postgis" install_postgresql
msg_info "Install/Set up PostgreSQL Database"
$STD apt-get install -y postgresql-16-postgis
msg_info "Set up PostgreSQL Database"
DB_NAME="adventurelog_db"
DB_USER="adventurelog_user"
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"

View File

@ -37,7 +37,7 @@ $STD apt-get install -y \
msg_ok "Installed Dependencies"
setup_uv
PG_VERSION="16" install_postgresql
PG_VERSION="16" PG_MODULES="contrib" install_postgresql
NODE_VERSION="22" install_node_and_modules
install_go
@ -61,8 +61,7 @@ cat <<EOF >/etc/GeoIP.conf
EOF
msg_ok "Installed GeoIP"
msg_info "Installing PostgreSQL"
$STD apt-get install -y postgresql-16 postgresql-contrib-16
msg_info "Setup PostgreSQL Database"
DB_NAME="authentik"
DB_USER="authentik"
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"

View File

@ -15,25 +15,26 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
postgresql \
apache2 \
libapache2-mod-php \
php-{pgsql,dom}
apache2 \
libapache2-mod-php \
php-{pgsql,dom}
msg_ok "Installed Dependencies"
msg_info "Setting up PostgreSQL"
PG_VERSION="16" install_postgresql
msg_info "Setting up PostgreSQL Database"
DB_NAME=baikal
DB_USER=baikal
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;"
{
echo "Baikal Credentials"
echo "Baikal Database User: $DB_USER"
echo "Baikal Database Password: $DB_PASS"
echo "Baikal Database Name: $DB_NAME"
echo "Baikal Credentials"
echo "Baikal Database User: $DB_USER"
echo "Baikal Database Password: $DB_PASS"
echo "Baikal Database Name: $DB_NAME"
} >>~/baikal.creds
msg_ok "Set up PostgreSQL"
msg_ok "Set up PostgreSQL Database"
msg_info "Installing Baikal"
RELEASE=$(curl -fsSL https://api.github.com/repos/sabre-io/Baikal/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')

View File

@ -15,12 +15,13 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
postgresql \
apache2 \
php-{curl,dom,json,ctype,pgsql,gmp,mbstring,iconv,zip} \
libapache2-mod-php
msg_ok "Installed Dependencies"
PG_VERSION="16" install_postgresql
msg_info "Setting up PostgreSQL"
DB_NAME=freshrss
DB_USER=freshrss

View File

@ -17,7 +17,6 @@ msg_info "Installing Dependencies"
$STD apt-get install -y \
apache2 \
redis-server \
postgresql \
build-essential \
libxml2-dev \
libxslt1-dev \
@ -27,6 +26,8 @@ $STD apt-get install -y \
zlib1g-dev
msg_ok "Installed Dependencies"
PG_VERSION="16" install_postgresql
msg_info "Installing Python"
$STD apt-get install -y \
python3 \

View File

@ -16,7 +16,6 @@ update_os
msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y \
redis \
postgresql \
build-essential \
imagemagick \
fonts-liberation \
@ -37,6 +36,8 @@ $STD apt-get install -y \
libleptonica-dev
msg_ok "Installed Dependencies"
PG_VERSION="16" install_postgresql
msg_info "Setup Python3"
$STD apt-get install -y \
python3 \

View File

@ -13,19 +13,7 @@ setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y gnupg
msg_ok "Installed Dependencies"
msg_info "Setting up PostgreSQL Repository"
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
echo "deb http://apt.postgresql.org/pub/repos/apt ${VERSION}-pgdg main" >/etc/apt/sources.list.d/pgdg.list
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor --output /etc/apt/trusted.gpg.d/postgresql.gpg
msg_ok "Setup PostgreSQL Repository"
msg_info "Installing PostgreSQL"
$STD apt-get update
$STD apt-get install -y postgresql
PG_VERSION="17" install_postgresql
cat <<EOF >/etc/postgresql/17/main/pg_hba.conf
# PostgreSQL Client Authentication Configuration File
@ -127,7 +115,7 @@ default_text_search_config = 'pg_catalog.english'
include_dir = 'conf.d'
EOF
sudo systemctl restart postgresql
systemctl restart postgresql
msg_ok "Installed PostgreSQL"
read -r -p "${TAB3}Would you like to add Adminer? <y/N> " prompt

View File

@ -122,20 +122,22 @@ install_node_and_modules() {
}
# ------------------------------------------------------------------------------
# Installs or upgrades PostgreSQL and performs data migration.
# Installs or upgrades PostgreSQL and optional extensions/modules.
#
# Description:
# - Detects existing PostgreSQL version
# - Dumps all databases before upgrade
# - Adds PGDG repo and installs specified version
# - Installs optional PG_MODULES (e.g. postgis, contrib)
# - Restores dumped data post-upgrade
#
# Variables:
# PG_VERSION - Major PostgreSQL version (e.g. 15, 16) (default: 16)
# PG_MODULES - Comma-separated list of extensions (e.g. "postgis,contrib")
# ------------------------------------------------------------------------------
install_postgresql() {
local PG_VERSION="${PG_VERSION:-16}"
local PG_MODULES="${PG_MODULES:-}"
local CURRENT_PG_VERSION=""
local DISTRO
local NEED_PG_INSTALL=false
@ -145,10 +147,10 @@ install_postgresql() {
CURRENT_PG_VERSION="$(psql -V | awk '{print $3}' | cut -d. -f1)"
if [[ "$CURRENT_PG_VERSION" == "$PG_VERSION" ]]; then
msg_ok "PostgreSQL $PG_VERSION is already installed"
return
else
msg_info "Detected PostgreSQL $CURRENT_PG_VERSION, preparing upgrade to $PG_VERSION"
NEED_PG_INSTALL=true
fi
msg_info "Detected PostgreSQL $CURRENT_PG_VERSION, preparing upgrade to $PG_VERSION"
NEED_PG_INSTALL=true
else
msg_info "Setup PostgreSQL $PG_VERSION"
NEED_PG_INSTALL=true
@ -179,20 +181,34 @@ install_postgresql() {
$STD apt-get install -y "postgresql-${PG_VERSION}" "postgresql-client-${PG_VERSION}"
if [[ -n "$CURRENT_PG_VERSION" ]]; then
$STD msg_info "Removing old PostgreSQL $CURRENT_PG_VERSION packages"
msg_info "Removing old PostgreSQL $CURRENT_PG_VERSION packages"
$STD apt-get purge -y "postgresql-${CURRENT_PG_VERSION}" "postgresql-client-${CURRENT_PG_VERSION}" || true
fi
$STD msg_info "Starting PostgreSQL $PG_VERSION"
msg_info "Starting PostgreSQL $PG_VERSION"
systemctl enable -q --now postgresql
if [[ -n "$CURRENT_PG_VERSION" ]]; then
$STD msg_info "Restoring dumped data"
msg_info "Restoring dumped data"
su - postgres -c "psql < /var/lib/postgresql/backup_$(date +%F)_v${CURRENT_PG_VERSION}.sql"
fi
msg_ok "PostgreSQL $PG_VERSION installed"
fi
# Install optional PostgreSQL modules
if [[ -n "$PG_MODULES" ]]; then
IFS=',' read -ra MODULES <<<"$PG_MODULES"
for module in "${MODULES[@]}"; do
local pkg="postgresql-${PG_VERSION}-${module}"
msg_info "Installing PostgreSQL module: $pkg"
$STD apt-get install -y "$pkg" || {
msg_error "Failed to install $pkg"
continue
}
done
msg_ok "All requested PostgreSQL modules installed"
fi
}
# ------------------------------------------------------------------------------