#!/usr/bin/env bash
# ox services catalog verification script
# entry: mongodb@8 (entry_version 2)
# generated by `ox catalog verify-script`; replay with: bash <this-file>
set -euo pipefail
if systemctl is-active --quiet mongod.service; then echo "mongodb@8: converged (unit active)"; exit 0; fi
# step: create /etc/apt/keyrings
install -d -m 0755 /etc/apt/keyrings
# step: fetch the mongodb-8.0 signing key
bash -c 'curl -fsSL --max-time 60 '\''https://www.mongodb.org/static/pgp/server-8.0.asc'\'' -o '\''/tmp/ox-key-mongodb-8.0.asc'\'' && test -s '\''/tmp/ox-key-mongodb-8.0.asc'\'''
# step: install the mongodb-8.0 keyring
install -o root -g root -m 0644 /tmp/ox-key-mongodb-8.0.asc /etc/apt/keyrings/mongodb-8.0.asc
# step: write the mongodb-8.0 sources list
bash -c 'printf '\''%s'\'' '\''Types: deb
URIs: https://repo.mongodb.org/apt/ubuntu
Suites: noble/mongodb-org/8.0
Components: multiverse
Signed-By: /etc/apt/keyrings/mongodb-8.0.asc
'\'' > '\''/tmp/ox-source-mongodb-8.0.sources'\'''
# step: install the mongodb-8.0 sources list
install -o root -g root -m 0644 /tmp/ox-source-mongodb-8.0.sources /etc/apt/sources.list.d/ox-mongodb-8.0.sources
# step: refresh package index for mongodb@8
apt-get update -qq
# step: install mongodb-org-server mongodb-database-tools
bash -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends mongodb-org-server mongodb-database-tools'
# step: enable mongod.service
systemctl enable --now mongod.service
# step: wait for tcp://127.0.0.1:27017
bash -c 'for i in $(seq 1 30); do timeout 1 bash -c "exec 3<>/dev/tcp/127.0.0.1/27017" 2>/dev/null && exit 0; sleep 2; done; exit 1'
