-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced PostgreSQL setup script: (#607)
- 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
Showing
1 changed file
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |