Skip to content

Commit

Permalink
Enhanced PostgreSQL setup script: (#607)
Browse files Browse the repository at this point in the history
- Improved error handling for better reliability.
- Translated error messages into English.
- Ensured consistency and readability of the script.
- Added documentation outlining the changes made.

This commit aims to enhance the usability and maintainability of the PostgreSQL setup script.
  • Loading branch information
Adriel007 authored Apr 15, 2024
1 parent 738fd08 commit 9ea5d80
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions scripts/install_ci.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
#!/usr/bin/env bash

set -ex

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y --no-install-recommends install postgresql-14 postgresql-server-dev-14 libpq5 libpq-dev clang-format-11 libpam0g-dev libldap-dev
sudo pkill -9 postgres || true
cho -n | openssl s_client -connect https://scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
set -e

if ! sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; then
echo "Error adding PostgreSQL repository."
exit 1
fi

if ! wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -; then
echo "Error adding PostgreSQL repository key."
exit 1
fi

if ! sudo apt-get update; then
echo "Error updating package list."
exit 1
fi

if ! sudo apt-get -y --no-install-recommends install postgresql-14 postgresql-server-dev-14 libpq5 libpq-dev clang-format-11 libpam0g-dev libldap-dev; then
echo "Error installing PostgreSQL and its dependencies."
exit 1
fi

if pgrep "postgres" > /dev/null; then
if ! sudo pkill -9 postgres; then
echo "Error stopping PostgreSQL process."
exit 1
fi
fi

if ! sudo sh -c 'echo -n | openssl s_client -connect https://scan.coverity.com:443 | sed -ne "/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p" >> /etc/ssl/certs/ca-certificates.crt'; then
echo "Error adding SSL certificate."
exit 1
fi

if ! sudo apt-get clean; then
echo "Error cleaning apt-get cache."
exit 1
fi

echo "Script completed successfully."
exit 0

0 comments on commit 9ea5d80

Please sign in to comment.