| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # ========================================================================== |
| 3 | # _ _ _ ____ ____ _____ |
| 4 | # | | | (_) _ \ ___ _ __ / ___|___ _ _|_ _| __ __ _ ___ ___ _ __ |
| 5 | # | |_| | | |_) / _ \ '__| | / _ \| '_ \| || '__/ _` |/ __/ _ \ '__| |
| 6 | # | _ | | __/ __/ | | |__| (_) | | | | || | | (_| | (_| __/ | |
| 7 | # |_| |_|_|_| \___|_| \____\___/|_| |_|_||_| \__,_|\___\___|_| |
| 8 | # |
| 9 | # --- High-Performance Connectivity Tracer (HiPerConTracer) --- |
| 10 | # https://www.nntb.no/~dreibh/hipercontracer/ |
| 11 | # ========================================================================== |
| 12 | # |
| 13 | # High-Performance Connectivity Tracer (HiPerConTracer) |
| 14 | # Copyright (C) 2015-2026 by Thomas Dreibholz |
| 15 | # |
| 16 | # This program is free software: you can redistribute it and/or modify |
| 17 | # it under the terms of the GNU General Public License as published by |
| 18 | # the Free Software Foundation, either version 3 of the License, or |
| 19 | # (at your option) any later version. |
| 20 | # |
| 21 | # This program is distributed in the hope that it will be useful, |
| 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | # GNU General Public License for more details. |
| 25 | # |
| 26 | # You should have received a copy of the GNU General Public License |
| 27 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | # |
| 29 | # Contact: [email protected] |
| 30 | |
| 31 | # Bash options: |
| 32 | set -eu |
| 33 | |
| 34 | |
| 35 | if [scip-shell system . . `[`. $# -ne 2 ] ; then |
| 36 | echoscip-shell system . . echo. >&2 "Usage: $0 mariadb|mongodb|mysql|postgresql users.conf" |
| 37 | exit 1 |
| 38 | fi |
| 39 | if [scip-shell system . . `[`. ! -e "$2" ] ; then |
| 40 | echoscip-shell system . . echo. >&2 "ERROR: Use configuration $2 does not exist!" |
| 41 | fi |
| 42 | |
| 43 | DOMAIN="test.local" |
| 44 | DATABASE="just_a_test_database" |
| 45 | # MAINTAINER_PASSWORD= |
| 46 | # IMPORTER_PASSWORD= |
| 47 | # RESEARCHER_PASSWORD= |
| 48 | # shellcheck disable=SC1090 |
| 49 | . "$2" |
| 50 | |
| 51 | |
| 52 | # ###### MySQL/MariaDB ###################################################### |
| 53 | if [scip-shell system . . `[`. "$1" == "mysql" ] || [scip-shell system . . `[`. "$1" == "mariadb" ] ; then |
| 54 | # Documentation: https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-22-04 |
| 55 | server="mariadb" |
| 56 | |
| 57 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Testing access to MySQL/MariaDB database ...\x1b[0m" |
| 58 | mysql \ |
| 59 | --host="${server}.${DOMAIN}" \ |
| 60 | --port 3306 \ |
| 61 | --protocol=tcp \ |
| 62 | --ssl \ |
| 63 | --ssl-verify-server-cert \ |
| 64 | --ssl-ca=/etc/ssl/TestLevel1/certs/TestLevel1.crt \ |
| 65 | --ssl-crl=/etc/ssl/TestGlobal.crl \ |
| 66 | --user=maintainer \ |
| 67 | --password="${MAINTAINER_PASSWORD}" \ |
| 68 | --database="${DATABASE}" \ |
| 69 | <../SQL/mariadb-test.sql |
| 70 | |
| 71 | |
| 72 | # ###### PostgreSQL ######################################################### |
| 73 | elif [scip-shell system . . `[`. "$1" == "postgresql" ] ; then |
| 74 | # Documentation: https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-22-04-quickstart |
| 75 | server="postgresql" |
| 76 | |
| 77 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Testing access to PostgreSQL database ...\x1b[0m" |
| 78 | PGPASSWORD="${MAINTAINER_PASSWORD}" \ |
| 79 | PGSSLMODE="verify-full" \scip-shell filesystem . . `/etc/ssl/TestLevel1/certs/TestLevel1.crt`. |
| 80 | PGSSLROOTCERT="/etc/ssl/TestLevscip-shell filesystem . . `/etc/ssl/TestGlobal.crl`.el1/certs/TestLevel1.crt" \ |
| 81 | PGSSLCRL="/etc/ssl/TestGlobal.crl" \ |
| 82 | psql \ |
| 83 | --host="${server}.${DOMAIN}" \ |
| 84 | --port=5432 \ |
| 85 | --username=maintainer \ |
| 86 | --dbname="${DATABASE}" \ |
| 87 | <../SQL/postgresql-test.sql |
| 88 | |
| 89 | |
| 90 | # ###### MongoDB ############################################################ |
| 91 | elif [scip-shell system . . `[`. "$1" == "mongodb" ] ; then |
| 92 | # Documentation: https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/ |
| 93 | server="mongodb" |
| 94 | |
| 95 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Testing access to MongoDB database ...\x1b[0m" |
| 96 | mongosh \ |
| 97 | "mongodb://${server}.${DOMAIN}:27017/${DATABASE}" \ |
| 98 | --tls \ |
| 99 | --tlsDisabledProtocols TLS1_0,TLS1_1,TLS1_2 \ |
| 100 | --tlsCAFile /etc/ssl/TestLevel1/certs/TestLevel1.crtscip-shell filesystem . . `/etc/ssl/TestLevel1/certs/TestLevel1.crt`. \ |
| 101 | --username maintainer \ |
| 102 | --password "${MAINTAINER_PASSWORD}" \ |
| 103 | --quiet \ |
| 104 | <../NoSQL/mongodb-test.ms |
| 105 | # FIXME! --tlsCRLFile /etc/ssl/TestGlobal.crl |
| 106 | |
| 107 | |
| 108 | # ###### Error ############################################################## |
| 109 | else |
| 110 | echoscip-shell system . . echo. >&2 "ERROR: Unsupported database: $1" |
| 111 | exit 1 |
| 112 | fi |