Last active
July 30, 2025 19:38
-
-
Save sandromello/c55033603295b019b73f1b15215b2ff2 to your computer and use it in GitHub Desktop.
hoop-gateway-install.sh
This file contains hidden or 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
| #!/bin/bash | |
| PGPASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c 43 | xargs) | |
| set -eo pipefail | |
| function echo_normal() { | |
| echo $'\e[1G----->' "$*" | |
| } | |
| VERSION=1.38.6 | |
| HOOP_DIR=/opt/hoop-$VERSION | |
| if [ -d "$HOOP_DIR" ]; then | |
| echo_normal "Hoop version ${VERSION} already installed" | |
| exit 1 | |
| fi | |
| echo_normal "downloading hoop gateway package ${VERSION}" | |
| curl -sL https://hoopartifacts.s3.amazonaws.com/release/hoopgateway_${VERSION}-gcp-Linux_amd64.tar.gz -o hoopgateway_${VERSION}-gcp-Linux_amd64.tar.gz | |
| # make sure the migration path doesn't have any files | |
| rm -rf /opt/hoop/migrations | |
| tar --extract --file hoopgateway_${VERSION}-gcp-Linux_amd64.tar.gz -C / --strip 1 2>/dev/null && rm -f hoopgateway_${VERSION}-gcp-Linux_amd64.tar.gz | |
| # TODO: remove me | |
| mv /opt/hoop $HOOP_DIR | |
| echo_normal "cleaning up old installations" | |
| systemctl stop hoopgateway || true | |
| systemctl stop hoopagent || true | |
| systemctl disable hoopgateway || true | |
| systemctl disable hoopagent || true | |
| systemctl daemon-reload | |
| echo_normal "configuring version ${VERSION} on system with symlinks" | |
| mkdir -p /etc/hoopgateway.d | |
| rm -f /etc/hoopgateway.d/config && ln -s $HOOP_DIR/etc/hoopgateway.d/config /etc/hoopgateway.d/config | |
| rm -f /etc/systemd/system/hoopgateway.service && ln -s $HOOP_DIR/etc/systemd/system/hoopgateway.service /etc/systemd/system/hoopgateway.service | |
| rm -f /etc/systemd/system/hoopagent.service && ln -s $HOOP_DIR/etc/systemd/system/hoopagent.service /etc/systemd/system/hoopagent.service | |
| rm -f /opt/hoop && ln -s $HOOP_DIR /opt/hoop | |
| # TODO: add step to obtain Postgres credentials / host from secrets manager to use managed databases | |
| if [ ! -f /etc/hoopgateway.d/postgres-credentials ]; then | |
| echo_normal "setting default Postgres credentials" | |
| # use the default Postgres user to set the initial password | |
| su postgres -c psql <<EOF | |
| ALTER USER postgres WITH ENCRYPTED PASSWORD '$PGPASSWORD'; | |
| EOF | |
| # test user authentication | |
| PGPASSWORD=$PGPASSWORD psql -h 0 --port 5432 -U postgres -d postgres -c "SELECT VERSION();" | |
| echo_normal "initial Postgres credentials configured with success" | |
| echo "POSTGRES_DB_URI=postgres://postgres:$PGPASSWORD@127.0.0.1:5432/postgres" > /etc/hoopgateway.d/postgres-credentials | |
| chmod 0600 /etc/hoopgateway.d/postgres-credentials | |
| fi | |
| echo_normal "reloading services" | |
| systemctl daemon-reload | |
| systemctl enable hoopgateway.service | |
| systemctl enable hoopagent.service | |
| systemctl start hoopgateway.service | |
| systemctl start hoopagent.service | |
| echo_normal "version ${VERSION} installed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment