Skip to content

Commit 3ee26ae

Browse files
Add installation support for Amazon Linux 2023
1 parent 448699e commit 3ee26ae

2 files changed

Lines changed: 68 additions & 40 deletions

File tree

install-labkey.bash

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function step_os_prereqs() {
354354
fi
355355
sudo dnf update -y
356356
sudo dnf upgrade --security --assumeyes --releasever=latest
357-
sudo dnf install -y "$ADOPTOPENJDK_VERSION"
357+
sudo dnf install -y "$ADOPTOPENJDK_VERSION" tomcat-native.x86_64 apr fontconfig
358358
fi
359359
;;
360360

@@ -702,59 +702,85 @@ function step_postgres_configure() {
702702

703703
case "_$(platform)" in
704704
_amzn)
705-
# Install the Postgresql repository RPM
706-
# note this method is required for AMZN linux and supports PG versions 12-15 - v16 not supported by PG repo
707-
if [[ -z $POSTGRES_VERSION ]]; then
708-
DEFAULT_POSTGRES_VERSION="15"
709-
else
710-
DEFAULT_POSTGRES_VERSION=$POSTGRES_VERSION
711-
fi
705+
if [ "$(platform_version)" != "2023" ]; then
706+
# Install the Postgresql repository RPM
707+
# note this method is required for AMZN linux and supports PG versions 12-15 - v16 not supported by PG repo
708+
if [[ -z $POSTGRES_VERSION ]]; then
709+
DEFAULT_POSTGRES_VERSION="15"
710+
else
711+
DEFAULT_POSTGRES_VERSION=$POSTGRES_VERSION
712+
fi
712713

713-
if [ ! -f "/etc/yum.repos.d/pgdg.repo" ]; then
714-
NewPGRepoFile="/etc/yum.repos.d/pgdg.repo"
715-
(
716-
/bin/cat <<-PG_REPO_HERE
714+
if [ ! -f "/etc/yum.repos.d/pgdg.repo" ]; then
715+
NewPGRepoFile="/etc/yum.repos.d/pgdg.repo"
716+
(
717+
/bin/cat <<-PG_REPO_HERE
717718
[pgdg$DEFAULT_POSTGRES_VERSION]
718719
name=PostgreSQL $DEFAULT_POSTGRES_VERSION for RHEL/CentOS 7 - x86_64
719720
baseurl=https://download.postgresql.org/pub/repos/yum/$DEFAULT_POSTGRES_VERSION/redhat/rhel-7-x86_64
720721
enabled=1
721722
gpgcheck=0
722723
723724
PG_REPO_HERE
724-
) >"$NewPGRepoFile"
725-
fi
725+
) >"$NewPGRepoFile"
726+
fi
726727

727-
if [ "$POSTGRES_SVR_LOCAL" == "TRUE" ]; then
728-
sudo yum clean metadata
729-
sudo yum update -y
730-
sudo yum install "postgresql$DEFAULT_POSTGRES_VERSION-server" -y
731-
# TODO: These are pre-reqs for Amazon Linux - Move to the pre-reqs function
732-
sudo yum install tomcat-native.x86_64 apr fontconfig -y
728+
if [ "$POSTGRES_SVR_LOCAL" == "TRUE" ]; then
729+
sudo yum clean metadata
730+
sudo yum update -y
731+
sudo yum install "postgresql$DEFAULT_POSTGRES_VERSION-server" -y
732+
# TODO: These are pre-reqs for Amazon Linux - Move to the pre-reqs function
733+
sudo yum install tomcat-native.x86_64 apr fontconfig -y
733734

734-
if [ ! -f "/var/lib/pgsql/data/$DEFAULT_POSTGRES_VERSION" ]; then
735-
# Handle differing paths between Amazon Linux 2 and Amazon Linux 2023
736-
if [ -f "/usr/pgsql-$DEFAULT_POSTGRES_VERSION/bin/postgresql-$DEFAULT_POSTGRES_VERSION-setup" ]; then
735+
if [ ! -f "/var/lib/pgsql/data/$DEFAULT_POSTGRES_VERSION" ]; then
737736
"/usr/pgsql-$DEFAULT_POSTGRES_VERSION/bin/postgresql-$DEFAULT_POSTGRES_VERSION-setup" initdb "postgresql-$DEFAULT_POSTGRES_VERSION"
738-
elif [ -f "/usr/bin/postgresql-setup" ]; then
739-
"/usr/bin/postgresql-setup" initdb "postgresql-$DEFAULT_POSTGRES_VERSION"
740-
else
741-
console_msg "Error: Unable to find Postgres Setup! ..."
742737
fi
738+
sudo systemctl start "postgresql-$DEFAULT_POSTGRES_VERSION"
739+
sudo -u postgres psql -c "create user $POSTGRES_USER password '$POSTGRES_PASSWORD';"
740+
sudo -u postgres psql -c "create database $POSTGRES_DB with owner $POSTGRES_USER;"
741+
sudo -u postgres psql -c "revoke all on database $POSTGRES_DB from public;"
742+
sed -i 's/host all all 127.0.0.1\/32 ident/host all all 127.0.0.1\/32 md5/' "/var/lib/pgsql/$DEFAULT_POSTGRES_VERSION/data/pg_hba.conf"
743+
sudo systemctl restart "postgresql-$DEFAULT_POSTGRES_VERSION"
744+
console_msg "Postgres Server and Client Installed ..."
745+
else
746+
sudo yum clean metadata
747+
sudo yum install "postgresql-client-$DEFAULT_POSTGRES_VERSION" -y
748+
# TODO: These are pre-reqs for Amazon Linux - Move to the pre-reqs function
749+
sudo yum install tomcat-native.x86_64 apr fontconfig -y
750+
console_msg "Postgres Client Installed ..."
743751
fi
744-
sudo systemctl enable "postgresql-$DEFAULT_POSTGRES_VERSION"
745-
sudo systemctl start "postgresql-$DEFAULT_POSTGRES_VERSION"
746-
sudo -u postgres psql -c "create user $POSTGRES_USER password '$POSTGRES_PASSWORD';"
747-
sudo -u postgres psql -c "create database $POSTGRES_DB with owner $POSTGRES_USER;"
748-
sudo -u postgres psql -c "revoke all on database $POSTGRES_DB from public;"
749-
sed -i 's/host all all 127.0.0.1\/32 ident/host all all 127.0.0.1\/32 md5/' "/var/lib/pgsql/$DEFAULT_POSTGRES_VERSION/data/pg_hba.conf"
750-
sudo systemctl restart "postgresql-$DEFAULT_POSTGRES_VERSION"
751-
console_msg "Postgres Server and Client Installed ..."
752752
else
753-
sudo yum clean metadata
754-
sudo yum install "postgresql-client-$DEFAULT_POSTGRES_VERSION" -y
755-
# TODO: These are pre-reqs for Amazon Linux - Move to the pre-reqs function
756-
sudo yum install tomcat-native.x86_64 apr fontconfig -y
757-
console_msg "Postgres Client Installed ..."
753+
if [ "$(platform_version)" == "2023" ]; then
754+
# AL 2023 supports installing Postgresql 15, 16, or 16 from its repo - however, only one version can be installed
755+
# default to v15 unless another version is supplied
756+
if [[ -z $POSTGRES_VERSION ]]; then
757+
DEFAULT_POSTGRES_VERSION="15"
758+
else
759+
DEFAULT_POSTGRES_VERSION=$POSTGRES_VERSION
760+
fi
761+
762+
if [ "$POSTGRES_SVR_LOCAL" == "TRUE" ]; then
763+
sudo dnf install "postgresql$DEFAULT_POSTGRES_VERSION-server" -y
764+
765+
if [ ! -f "/var/lib/pgsql/data/PG_VERSION" ]; then
766+
sudo /usr/bin/postgresql-setup initdb
767+
fi
768+
sudo systemctl enable postgresql
769+
sudo systemctl start postgresql
770+
sudo -u postgres psql -c "create user $POSTGRES_USER password '$POSTGRES_PASSWORD';"
771+
sudo -u postgres psql -c "create database $POSTGRES_DB with owner $POSTGRES_USER;"
772+
sudo -u postgres psql -c "revoke all on database $POSTGRES_DB from public;"
773+
sed -i 's/host all all 127.0.0.1\/32 ident/host all all 127.0.0.1\/32 md5/' "/var/lib/pgsql/data/pg_hba.conf"
774+
sudo systemctl restart postgresql
775+
console_msg "Postgres Server and Client Installed ..."
776+
else
777+
sudo dnf clean metadata
778+
sudo dnf install "postgresql$DEFAULT_POSTGRES_VERSION" -y
779+
console_msg "Postgres Client Installed ..."
780+
fi
781+
else
782+
console_msg "Error: Postgresql install on Amazon Linux version $(platform_version) not supported ..."
783+
fi
758784
fi
759785
;;
760786

sample_embedded_envs.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export LABKEY_BASE_SERVER_URL="https://localhost"
1111
#export LABKEY_INSTALL_SKIP_REQUIRED_ENVS_STEP=1
1212
#export LABKEY_INSTALL_SKIP_START_LABKEY_STEP=1
1313
export POSTGRES_SVR_LOCAL="TRUE"
14+
# Default POSTGRES version is 15, use this var to specify v16, 17 etc
15+
#export POSTGRES_VERSION="16"
1416

1517
export LABKEY_DIST_URL="https://lk-binaries.s3.us-west-2.amazonaws.com/downloads/release/community/25.7.7/LabKey25.7.7-8-community.tar.gz"
1618
export LABKEY_DIST_FILENAME="LabKey25.7.7-8-community.tar.gz"

0 commit comments

Comments
 (0)