#!/usr/bin/env bash
# ox services catalog verification script
# entry: mysql@8 (entry_version 1)
# generated by `ox catalog verify-script`; replay with: bash <this-file>
set -euo pipefail
if systemctl is-active --quiet mysql.service; then echo "mysql@8: converged (unit active)"; exit 0; fi
# step: refresh package index for mysql@8
apt-get update -qq
# step: install mysql-server
bash -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends mysql-server'
# step: enable mysql.service
systemctl enable --now mysql.service
# step: wait for tcp://127.0.0.1:3306
bash -c 'for i in $(seq 1 30); do timeout 1 bash -c "exec 3<>/dev/tcp/127.0.0.1/3306" 2>/dev/null && exit 0; sleep 2; done; exit 1'
# step: run
bash -c 'env MYSQL_PASSWORD='\''0xvERIFYcredential1234567890ABCDEFGH'\'' mysql -e '\''CREATE USER IF NOT EXISTS "verify"@"127.0.0.1" IDENTIFIED BY "0xvERIFYcredential1234567890ABCDEFGH";
ALTER USER "verify"@"127.0.0.1" IDENTIFIED BY "0xvERIFYcredential1234567890ABCDEFGH";
CREATE DATABASE IF NOT EXISTS `verify`;
GRANT ALL PRIVILEGES ON `verify`.* TO "verify"@"127.0.0.1";'\'''
