#3505 lnbits PostgresSQl migration finalization (#3507)

* fix missing dependencies

* LNBits SQLite to PostgreSQL migration (#3411)

* LNBits SQLite to PostgreSQL migration

New installations with PostgreSQL configuration, existent data with SQLite.

convert script needs a full start of LNBits prior migrating the old sqlite db's.

User can migrate from raspiblitz menu.

* only fix postgres if it needs to

check for symbolik link of postgres default directory or desired postgres folder

btcpayserver and lnbits could use postgresql

new script to install or uninstall postgresql

* fix typos

* silent apt remove

* fix removed function postgresConfig

call bonus.postgresql.sh to setup PostgreSQL

* Support outdated installation

old installations should upgrade to new tag first

create new data directory /mnt/hdd/app-data/LNBits/data

* Improve migration

Make it a bit more user friendly and prepare for a worst case to revert the migration if something fails unexpectedly

make use of sync method for preparation

* Rework migration workflow

Cant wait for lnbits to start when ExecStartPre is used.

We need a full start of lnbits prior migration, so make use of lsof to check for ports and wait.

dont forget to start postgres service after installation. dont forget to stop postgres after uninstall

* Dont overwrite the backup file

if we start migrate again, the sqlite backup should not be overwritten with postgres data. Keep the backup file.

* add migrate message to menu

add the hint to revert migration manually after migrate script executed

* fix install and data directory

lnbits always needs a data directory

* clean up lnbits settings for migration

even if postgresql is already running, we can extract sqlite backup and start migrate

remove migrateMsg duplicate

* preserve database for reflash

drop database only for migrate, not for regular installations

* set blitz config for LNBits

fix drop database only for migrate, not for regular installations

* Add confirmation dialog and automatic revert

User needs to confirm the process, this will eliminate missclicks

add a migrate revert function to automatically revert if something unexpected happens

let the user call the function manually

* check conv.py on success or revert

if the conversion script fails, revert automatically

* Improve revert message

Do not print the revert hint message if current database is SQLite

* fix read config LNBitsDB

* fix unpack backup

Folder LNBits should never block the restore of backup. Happened after multiple migrations and revert.

* Wait for lnbits v0.9.5

Set commit version with fix for postgresql database and BIGINT for amounts for migrate

Can be set to v0.9.5 tag or above later

* improve migrate backup handling

revert to the current backup and not to the previous backup.

No need for the failed folder state

user message with backup file path

* check psql version once

* supress expected errors

if database exists

Co-authored-by: /rootzoll <christian@geektank.de>

* fix error output on status

Co-authored-by: ChuckNorrison <2964146+ChuckNorrison@users.noreply.github.com>
This commit is contained in:
/rootzoll 2022-12-10 00:04:15 +01:00 committed by GitHub
parent 9d23c63c38
commit d7d1c40866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 365 additions and 57 deletions

View file

@ -313,18 +313,6 @@ sudo apt clean -y
sudo apt autoremove -y
echo -e "\n*** Python DEFAULT libs & dependencies ***"
# make sure /usr/bin/pip exists (and calls pip3 in Debian Buster)
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# 1. libs (for global python scripts)
# grpcio==1.42.0 googleapis-common-protos==1.53.0 toml==0.10.2 j2cli==0.3.10 requests[socks]==2.21.0
# 2. For TorBox bridges python scripts (pip3) https://github.com/radio24/TorBox/blob/master/requirements.txt
# pytesseract mechanize PySocks urwid Pillow requests
# 3. Nyx
# setuptools
python_libs="grpcio==1.42.0 googleapis-common-protos==1.53.0 toml==0.10.2 j2cli==0.3.10 requests[socks]==2.21.0 protobuf==3.20.1 wrapt==1.14.1"
torbox_libs="pytesseract mechanize PySocks urwid Pillow requests setuptools"
sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install ${python_libs} ${torbox_libs}
if [ -f "/usr/bin/python3.9" ]; then
# use python 3.9 if available
@ -345,6 +333,18 @@ else
exit 1
fi
# make sure /usr/bin/pip exists (and calls pip3 in Debian Buster)
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# 1. libs (for global python scripts)
# grpcio==1.42.0 googleapis-common-protos==1.53.0 toml==0.10.2 j2cli==0.3.10 requests[socks]==2.21.0
# 2. For TorBox bridges python scripts (pip3) https://github.com/radio24/TorBox/blob/master/requirements.txt
# pytesseract mechanize PySocks urwid Pillow requests
# 3. Nyx
# setuptools
sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install grpcio==1.42.0 googleapis-common-protos==1.53.0 toml==0.10.2 j2cli==0.3.10 requests[socks]==2.21.0 protobuf==3.20.1 pathlib2==2.3.7.post1
sudo -H python3 -m pip install pytesseract mechanize PySocks urwid Pillow requests setuptools
echo -e "\n*** PREPARE ${baseimage} ***"
# make sure the pi user is present

33
home.admin/config.scripts/bonus.btcpayserver.sh Executable file → Normal file
View file

@ -25,36 +25,8 @@ source /home/admin/raspiblitz.info
source <(/home/admin/_cache.sh get state)
function postgresConfig() {
# https://github.com/rootzoll/raspiblitz/issues/3218
echo "# Install postgres"
if sudo apt install -y postgresql-13; then
PGVERSION=13
elif sudo apt install -y postgresql-12; then
PGVERSION=12
fi
# sudo -u postgres psql -c "show data_directory"
# /var/lib/postgresql/13/main
if [ ! -d /var/lib/postgresql/${PGVERSION}/main ]; then
sudo mkdir -p /var/lib/postgresql/${PGVERSION}/main
sudo chown -R postgres:postgres /var/lib/postgresql
sudo systemctl start postgresql@${PGVERSION}-main
fi
if [ ! -L /var/lib/postgresql ]; then
echo "# Move the postgres data to /mnt/hdd/app-data/postgresql"
# stop the postgresql servers
sudo su - postgres -c "/usr/lib/postgresql/${PGVERSION}/bin/pg_ctl stop --wait --pgdata=/var/lib/postgresql/${PGVERSION}/main"
sudo systemctl stop postgresql@${PGVERSION}-main
sudo rsync -av /var/lib/postgresql /mnt/hdd/app-data
sudo mv /var/lib/postgresql /var/lib/postgresql.bak
sudo rm -rf /var/lib/postgresql # not a symlink.. delete it silently
sudo ln -s /mnt/hdd/app-data/postgresql /var/lib/
sudo chown -R postgres:postgres /mnt/hdd/app-data/postgresql
sudo chmod -R 0700 /mnt/hdd/app-data/postgresql
# start
sudo systemctl start postgresql@${PGVERSION}-main
fi
echo "# Check clusters with: pg_lsclusters"
pg_lsclusters
sudo /home/admin/config.scripts/bonus.postgresql.sh on || exit 1
echo "# Generate the database"
sudo -u postgres psql -c "create database nbxplorermainnet;"
@ -751,6 +723,7 @@ if [ "$1" = "update" ]; then
sudo systemctl restart bitcoind
fi
# POSTGRES
postgresConfig
NBXplorerConfig

View file

@ -18,12 +18,103 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "bonus.lnbits.sh prestart"
echo "bonus.lnbits.sh repo [githubuser] [branch]"
echo "bonus.lnbits.sh sync"
echo "bonus.lnbits.sh migrate"
exit 1
fi
echo "# Running: 'bonus.lnbits.sh $*'"
source /mnt/hdd/raspiblitz.conf
function postgresConfig() {
sudo /home/admin/config.scripts/bonus.postgresql.sh on || exit 1
echo "# Generate the database lnbits_db"
# migrate clean up
source <(/home/admin/_cache.sh get LNBitsMigrate)
if [ "${LNBitsMigrate}" == "on" ]; then
sudo -u postgres psql -c "drop database lnbits_db;"
sudo -u postgres psql -c "drop user lnbits_user;"
fi
# create database for new installations and keep old
sudo -u postgres psql -c "create database lnbits_db;" 2>/dev/null
sudo -u postgres psql -c "create user lnbits_user with encrypted password 'raspiblitz';" 2>/dev/null
sudo -u postgres psql -c "grant all privileges on database lnbits_db to lnbits_user;" 2>/dev/null
# check
check=$(sudo -u postgres psql -c "SELECT datname FROM pg_database;" | grep lnbits_db)
if [ "$check" = "" ]; then
echo "# postgresConfig failed -> SELECT datname FROM pg_database;"
exit 1
else
echo "# Setup PostgreSQL successful, new database found: $check"
fi
/home/admin/config.scripts/blitz.conf.sh set LNBitsDB "PostgreSQL"
}
function migrateMsg() {
source <(/home/admin/_cache.sh get LNBitsDB)
if [ "${LNBitsDB}" == "PostgreSQL" ]; then
if [ -e /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar ]; then
echo "SUCCESS - A backup file was found. The migrate progress will revert automatically on failure."
echo "For yet unknown reasons, this could be done manually with unpacking the SQLite backup file."
echo
echo "/home/admin/config.scripts/bonus.lnbits.sh migrate revert"
echo
echo "********************************************************"
echo "* *"
echo "* Revert: /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar *"
echo "* *"
echo "********************************************************"
echo
else
echo "You dont have any migration backup files!"
fi
else
echo "ABORT - Your LNBits is still running on old SQLite database."
echo "Check for errors, '.dump' and fix your database manually and try again."
fi
}
function revertMigration() {
source <(/home/admin/_cache.sh get LNBitsMigrate)
if [ "${LNBitsMigrate}" == "on" ]; then
echo "# Revert migration, restore SQLite..."
sudo systemctl stop lnbits
# check current backup
if [ -e /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar ]; then
echo "# Unpack Backup"
cd /mnt/hdd/app-data/
sudo rm -R /mnt/hdd/app-data/LNBits
sudo tar -xf /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar
sudo chown lnbits:lnbits -R /mnt/hdd/app-data/LNBits
else
echo "# No backup file found!"
fi
# update config
echo "# Configure config .env"
# clean up
sudo sed -i "/^LNBITS_DATABASE_URL=/d" /home/lnbits/lnbits/.env
sudo sed -i "/^LNBITS_DATA_FOLDER=/d" /home/lnbits/lnbits/.env
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits' >> /home/lnbits/lnbits/.env"
# start service
echo "# Start LNBits"
sudo systemctl start lnbits
# set blitz config
/home/admin/config.scripts/blitz.conf.sh set LNBitsMigrate "off"
/home/admin/config.scripts/blitz.conf.sh set LNBitsDB "SQLite"
echo "# OK revert migration done"
else
echo "# No migration started yet, nothing to do."
fi
}
# show info menu
if [ "$1" = "menu" ]; then
@ -117,6 +208,11 @@ Consider adding a IP2TOR Bridge under OPTIONS."
OPTIONS+=(SWITCH-LND "Switch: Use LND as funding source")
fi
# Migrate SQLite to PostgreSQL
if [ -e /mnt/hdd/app-data/LNBits/database.sqlite3 ]; then
OPTIONS+=(MIGRATE-DB "Migrate SQLite to PostgreSQL database")
fi
WIDTH=66
CHOICE_HEIGHT=$(("${#OPTIONS[@]}/2+1"))
HEIGHT=$((CHOICE_HEIGHT+7))
@ -168,6 +264,27 @@ Consider adding a IP2TOR Bridge under OPTIONS."
read key
exit 0
;;
MIGRATE-DB)
clear
dialog --title "MIGRATE LNBITS" --yesno "
Do you want to proceed the migration?
Try to migrate your LNBits SQLite database to PostgreSQL.
This can fail for unknown circumstances. Revert of this process is possible afterwards, a backup will be saved.
" 12 65
if [ $? -eq 0 ]; then
clear
/home/admin/config.scripts/bonus.lnbits.sh migrate
echo
migrateMsg
echo
echo "OK please test your LNBits installation."
echo "PRESS ENTER to continue"
read key
fi
exit 0
;;
*)
clear
exit 0
@ -199,7 +316,7 @@ if [ "$1" = "status" ]; then
# check for LetsEnryptDomain for DynDns
error=""
source <(sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $publicIP)
source <(sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $publicIP 2>/dev/null)
if [ ${#error} -eq 0 ]; then
echo "publicDomain='${domain}'"
fi
@ -396,6 +513,7 @@ if [ "$1" = "sync" ] || [ "$1" = "repo" ]; then
sudo -u lnbits ./venv/bin/pip install pylightning
sudo -u lnbits ./venv/bin/pip install secp256k1
sudo -u lnbits ./venv/bin/pip install pyln-client
sudo -u lnbits ./venv/bin/pip install psycopg2 # conv.py postgres migration dependency
# build
sudo -u lnbits ./venv/bin/python build.py
@ -495,10 +613,29 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u lnbits touch /home/lnbits/lnbits/.env
sudo bash -c "echo 'LNBITS_FORCE_HTTPS=0' >> /home/lnbits/lnbits/.env"
# set database path to HDD data so that its survives updates and migrations
sudo mkdir /mnt/hdd/app-data/LNBits 2>/dev/null
if [ ! -e /mnt/hdd/app-data/LNBits/database.sqlite3 ]; then
echo "# install database: PostgreSQL"
# POSTGRES
postgresConfig
# new data directory
sudo mkdir -p /mnt/hdd/app-data/LNBits/data
# config update
# example: postgres://<user>:<password>@<host>/<database>
sudo bash -c "echo 'LNBITS_DATABASE_URL=postgres://lnbits_user:raspiblitz@localhost:5432/lnbits_db' >> /home/lnbits/lnbits/.env"
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits/data' >> /home/lnbits/lnbits/.env"
else
echo "# install database: SQLite"
/home/admin/config.scripts/blitz.conf.sh set LNBitsDB "SQLite"
# new data directory
sudo mkdir -p /mnt/hdd/app-data/LNBits
# config update
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits' >> /home/lnbits/lnbits/.env"
fi
sudo chown lnbits:lnbits -R /mnt/hdd/app-data/LNBits
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits' >> /home/lnbits/lnbits/.env"
# let switch command part do the detail config
/home/admin/config.scripts/bonus.lnbits.sh switch ${fundingsource}
@ -513,6 +650,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u lnbits ./venv/bin/pip install pylightning
sudo -u lnbits ./venv/bin/pip install secp256k1
sudo -u lnbits ./venv/bin/pip install pyln-client
sudo -u lnbits ./venv/bin/pip install psycopg2 # conv.py postgres migration dependency
# build
sudo -u lnbits ./venv/bin/python build.py
@ -524,9 +662,9 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo ufw allow 5001 comment 'lnbits HTTPS'
echo
# install service
echo "*** Install systemd ***"
cat <<EOF | sudo tee /etc/systemd/system/lnbits.service >/dev/null
# install service
echo "*** Install systemd ***"
cat <<EOF | sudo tee /etc/systemd/system/lnbits.service >/dev/null
# systemd unit for lnbits
[Unit]
@ -555,15 +693,15 @@ PrivateDevices=true
WantedBy=multi-user.target
EOF
sudo systemctl enable lnbits
sudo systemctl enable lnbits
source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then
echo "# OK - lnbits service is enabled, system is on ready so starting lnbits service"
sudo systemctl start lnbits
else
echo "# OK - lnbits service is enabled, but needs reboot or manual starting: sudo systemctl start lnbits"
fi
source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then
echo "# OK - lnbits service is enabled, system is on ready so starting lnbits service"
sudo systemctl start lnbits
else
echo "# OK - lnbits service is enabled, but needs reboot or manual starting: sudo systemctl start lnbits"
fi
# setup nginx symlinks
if ! [ -f /etc/nginx/sites-available/lnbits_ssl.conf ]; then
@ -772,6 +910,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
if [ ${deleteData} -eq 1 ]; then
echo "# deleting data"
sudo -u postgres psql -c "drop database lnbits_db;"
sudo -u postgres psql -c "drop user lnbits_user;"
sudo rm -R /mnt/hdd/app-data/LNBits
else
echo "# keeping data"
@ -785,5 +925,107 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
exit 0
fi
if [ "$1" = "migrate" ] && [ "$2" = "revert" ]; then
/home/admin/config.scripts/blitz.conf.sh set LNBitsMigrate "on"
revertMigration
exit 0
fi
if [ "$1" = "migrate" ]; then
if [ -e /mnt/hdd/app-data/LNBits/database.sqlite3 ]; then
echo "# Backup SQLite database"
# backup current database, but dont overwrite last backup
if [ -e /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar ]; then
if [ -e /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar.old ]; then
echo "# Remove old backup file"
sudo rm -f /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar.old
fi
# keep the last backup as old backup
sudo mv /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar.old
fi
# create new backup
sudo tar -cf /mnt/hdd/app-data/LNBits_sqlitedb_backup.tar -C /mnt/hdd/app-data LNBits/
# update to expected tag
cd /home/lnbits/lnbits || exit 1
# remove existent config for database
sudo sed -i "/^LNBITS_DATABASE_URL=/d" /home/lnbits/lnbits/.env 2>/dev/null
sudo sed -i "/^LNBITS_DATA_FOLDER=/d" /home/lnbits/lnbits/.env 2>/dev/null
# restore sqlite database config
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits' >> /home/lnbits/lnbits/.env"
#sudo -u lnbits git checkout ${tag}
sudo -u lnbits git reset --hard f3b720b690c533b4b28793209f5a71fd01b9af6e # good tested after BIGINT fix (#1030)
/home/admin/config.scripts/bonus.lnbits.sh sync || exit 1
# stop after sync was done
sudo systemctl stop lnbits
/home/admin/config.scripts/blitz.conf.sh set LNBitsMigrate "on"
# POSTGRES
postgresConfig
# example: postgres://<user>:<password>@<host>/<database>
# add new postgres config
sudo bash -c "echo 'LNBITS_DATABASE_URL=postgres://lnbits_user:raspiblitz@localhost:5432/lnbits_db' >> /home/lnbits/lnbits/.env"
# clean start on new postgres db prior migration
echo "# LNBits first start with clean PostgreSQL"
sudo systemctl start lnbits
# execStartPre is not enough, wait for lnbits is finally running
count=0
count_max=30
while ! nc -zv 127.0.0.1 5000 2>/dev/null;
do
count=`expr $count + 1`
echo "wait for LNBIts to start (${count}s/${count_max}s)"
sleep 1
if [ $count = $count_max ]; then
sudo systemctl status lnbits
echo "# FAIL - LNBits service was not able to start"
revertMigration
exit 1
fi
done
# wait a sec for "✔ All migrations done." (TODO make it pretty)
sleep 5
echo "# LNBits service looks good"
sudo systemctl stop lnbits
echo "# Start convert old SQLite to new PostgreSQL"
if ! sudo -u lnbits ./venv/bin/python tools/conv.py; then
echo "FAIL - Convert failed, revert migration process"
revertMigration
exit 1
else
echo "# Convert successful"
fi
# cleanup old sqlite data directory
echo "# Cleanup old data directory"
sudo rm -R /mnt/hdd/app-data/LNBits/
# new data directory
sudo mkdir -p /mnt/hdd/app-data/LNBits/data
sudo chown lnbits:lnbits -R /mnt/hdd/app-data/LNBits/
echo "# Configure .env"
sudo sed -i "/^LNBITS_DATA_FOLDER=/d" /home/lnbits/lnbits/.env 2>/dev/null
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits/data' >> /home/lnbits/lnbits/.env"
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set LNBitsMigrate "off"
echo "# OK migration done"
else
echo "# No SQLite data found to migrate from"
fi
sudo systemctl start lnbits
exit 0
fi
echo "FAIL - Unknown Parameter $1"
exit 1

View file

@ -0,0 +1,93 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to install PostgreSQL"
echo "bonus.postgresql.sh [on|off]"
exit 1
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# https://github.com/rootzoll/raspiblitz/issues/3218
echo "# Install PostgreSQL"
sudo apt install -y postgresql
postgres_datadir="/var/lib/postgresql" # default data dir
# sudo -u postgres psql -c "show data_directory"
# /var/lib/postgresql/13/main
if [ ! -d $postgres_datadir ]; then
echo "# Create PostgreSQL data"
sudo mkdir -p $postgres_datadir/13/main
sudo chown -R postgres:postgres $postgres_datadir
# sudo pg_dropcluster 13 main
sudo pg_createcluster 13 main --start
fi
fix_postgres=0
if [ -L $postgres_datadir ] ; then
if [ -e $postgres_datadir ] ; then
echo "# Good link in $postgres_datadir"
else
echo "# Broken link in $postgres_datadir"
fix_postgres=1
fi
elif [ -e $postgres_datadir ] ; then
echo "# Not a link in $postgres_datadir"
fix_postgres=1
else
echo "# Missing Link in $postgres_datadir"
fix_postgres=1
fi
if [ fix_postgres = 1 ] || [ ! -d /mnt/hdd/app-data/postgresql ]; then
echo "# Move the PostgreSQL data to /mnt/hdd/app-data/postgresql"
sudo systemctl stop postgresql 2>/dev/null
sudo rsync -av $postgres_datadir /mnt/hdd/app-data
sudo mv $postgres_datadir /var/lib/postgresql.bak
sudo rm -rf $postgres_datadir # not a symlink.. delete it silently
sudo ln -s /mnt/hdd/app-data/postgresql /var/lib/
fi
sudo systemctl enable postgresql
sudo systemctl start postgresql
# check if PostgreSQL was installed
if psql --version; then
# wait for the postgres server to start
count=0
count_max=30
while ! nc -zv 127.0.0.1 5432 2>/dev/null;
do
count=`expr $count + 1`
echo "sleep $count/$count_max"
sleep 1
if [ $count = $count_max ]; then
sudo systemctl status postgresql
echo "FAIL - Was not able to start PostgreSQL service"
exit 1
fi
done
echo "OK PostgreSQL installed"
else
echo "FAIL - Was not able to install PostgreSQL"
echo "ABORT - PostgreSQL install"
exit 1
fi
exit 0
fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config
echo "*** REMOVING POSTGRESQL ***"
sudo apt remove -y postgresql
sudo systemctl stop postgresql 2>/dev/null
sudo systemctl disable postgresql
echo "OK PostgreSQL removed."
exit 0
fi
echo "FAIL - Unknown Parameter $1"
exit 1