| 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 . . `[`. $# -lt 1 ] ; then |
| 36 | echoscip-shell system . . echo. >&2 "Usage: $0 mariadb|mongodb|mysql|postgresql [--force-removal-without-confirmation]" |
| 37 | exit 1 |
| 38 | fi |
| 39 | |
| 40 | if [scip-shell system . . `[`. $# -lt 2 ] || [scip-shell system . . `[`. "$2" != "--force-removal-without-confirmation" ] ; then |
| 41 | echoscip-shell system . . echo. -n "WARNING: THIS SCRIPT WILL ERASE THE EXISTING DATABASES. To proceed, type \"I am sure!\": " |
| 42 | read -er agree |
| 43 | if [scip-shell system . . `[`. "$agree" != "I am sure!" ] ; then |
| 44 | echoscip-shell system . . echo. "Exiting." |
| 45 | exit |
| 46 | fi |
| 47 | fi |
| 48 | |
| 49 | |
| 50 | # ====== Check/set environment variables ==================================== |
| 51 | if [scip-shell system . . `[`. ! -e /etc/os-releasescip-shell filesystem . . `/etc/os-release`. ] ; then |
| 52 | echoscip-shell system . . echo. >&2 "ERROR: /etc/os-release does not exist!" |
| 53 | exit 1 |
| 54 | fi |
| 55 | . /etc/os-releasescip-shell source . . `/etc/os-release`. |
| 56 | |
| 57 | |
| 58 | |
| 59 | # ###### MariaDB ############################################################ |
| 60 | if [scip-shell system . . `[`. "$1" == "mariadb" ] ; then |
| 61 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Uninstalling MariaDB ...\x1b[0m" |
| 62 | |
| 63 | if [scip-shell system . . `[`. "${ID}" == "ubuntu" ] || [scip-shell system . . `[`. "${ID}" == "debian" ] ; then |
| 64 | sudoscip-shell system . . sudo. DEBIAN_FRONTEND=noninteractive apt purge -y mariadb-client mariadb-server mariadb-backup |
| 65 | elif [scip-shell system . . `[`. "${ID}" == "fedora" ] ; then |
| 66 | sudoscip-shell system . . sudo. dnf remove -y 'mariadb-*' |
| 67 | elif [scip-shell system . . `[`. "${ID}" == "freebsd" ] ; then |
| 68 | sudoscip-shell system . . sudo. service mysql-server stop || truescip-shell system . . true. |
| 69 | sudoscip-shell system . . sudo. service mysql-server disable || truescip-shell system . . true. |
| 70 | sudoscip-shell system . . sudo. pkg remove -y 'mariadb*-server' || truescip-shell system . . true. |
| 71 | else |
| 72 | echoscip-shell system . . echo. >&2 "ERROR: Unknown ID ${ID} in /etc/os-release. The installation script may need an update for supporting this system!" |
| 73 | exit 1 |
| 74 | fi |
| 75 | |
| 76 | if [scip-shell system . . `[`. -d /var/lib/mysqlscip-shell filesystem . . `/var/lib/mysql`. ] ; then |
| 77 | sudoscip-shell system . . sudo. rm -rf /var/lib/mysqlscip-shell filesystem . . `/var/lib/mysql`. |
| 78 | fi |
| 79 | if [scip-shell system . . `[`. -d /var/db/mysqlscip-shell filesystem . . `/var/db/mysql`. ] ; then |
| 80 | sudoscip-shell system . . sudo. rm -rf /var/db/mysqlscip-shell filesystem . . `/var/db/mysql`. |
| 81 | fi |
| 82 | |
| 83 | |
| 84 | # ###### PostgreSQL ######################################################### |
| 85 | elif [scip-shell system . . `[`. "$1" == "postgresql" ] ; then |
| 86 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Uninstalling PostgreSQL ...\x1b[0m" |
| 87 | |
| 88 | if [scip-shell system . . `[`. "${ID}" == "ubuntu" ] || [scip-shell system . . `[`. "${ID}" == "debian" ] ; then |
| 89 | sudoscip-shell system . . sudo. DEBIAN_FRONTEND=noninteractive apt purge -y 'postgresql-*' |
| 90 | elif [scip-shell system . . `[`. "${ID}" == "fedora" ] ; then |
| 91 | sudoscip-shell system . . sudo. dnf remove -y 'postgresql-*' |
| 92 | elif [scip-shell system . . `[`. "${ID}" == "freebsd" ] ; then |
| 93 | sudoscip-shell system . . sudo. service postgresql stop || truescip-shell system . . true. |
| 94 | sudoscip-shell system . . sudo. pkg remove -y 'postgresql*-*' || truescip-shell system . . true. |
| 95 | else |
| 96 | echoscip-shell system . . echo. >&2 "ERROR: Unknown ID ${ID} in /etc/os-release. The installation script may need an update for supporting this system!" |
| 97 | exit 1 |
| 98 | fi |
| 99 | |
| 100 | if [scip-shell system . . `[`. -d /var/lib/postgresqlscip-shell filesystem . . `/var/lib/postgresql`. ] ; then |
| 101 | sudoscip-shell system . . sudo. rm -rf /var/lib/postgresqlscip-shell filesystem . . `/var/lib/postgresql`. |
| 102 | fi |
| 103 | if [scip-shell system . . `[`. -d /var/lib/pgsqlscip-shell filesystem . . `/var/lib/pgsql`. ] ; then |
| 104 | sudoscip-shell system . . sudo. rm -rf /var/lib/pgsqlscip-shell filesystem . . `/var/lib/pgsql`. |
| 105 | fi |
| 106 | if [scip-shell system . . `[`. -d /var/db/postgresscip-shell filesystem . . `/var/db/postgres`. ] ; then |
| 107 | sudoscip-shell system . . sudo. rm -rf /var/db/postgresscip-shell filesystem . . `/var/db/postgres`. |
| 108 | fi |
| 109 | |
| 110 | |
| 111 | # ###### MongoDB ############################################################ |
| 112 | elif [scip-shell system . . `[`. "$1" == "mongodb" ] ; then |
| 113 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Uninstalling MongoDB ...\x1b[0m" |
| 114 | |
| 115 | if [scip-shell system . . `[`. "${ID}" == "ubuntu" ] || [scip-shell system . . `[`. "${ID}" == "debian" ] ; then |
| 116 | sudoscip-shell system . . sudo. DEBIAN_FRONTEND=noninteractive apt purge -y 'mongodb-*' |
| 117 | elif [scip-shell system . . `[`. "${ID}" == "fedora" ] ; then |
| 118 | sudoscip-shell system . . sudo. dnf remove -y 'mongodb-*' |
| 119 | elif [scip-shell system . . `[`. "${ID}" == "freebsd" ] ; then |
| 120 | sudoscip-shell system . . sudo. service mongod stop || truescip-shell system . . true. |
| 121 | sudoscip-shell system . . sudo. pkg remove -y 'mongodb*' mongosh || truescip-shell system . . true. |
| 122 | sudoscip-shell system . . sudo. rm -f /usr/local/etc/mongodb.confscip-shell filesystem . . `/usr/local/etc/mongodb.conf`. || truescip-shell system . . true. |
| 123 | else |
| 124 | echoscip-shell system . . echo. >&2 "ERROR: Unknown ID ${ID} in /etc/os-release. The installation script may need an update for supporting this system!" |
| 125 | exit 1 |
| 126 | fi |
| 127 | |
| 128 | if [scip-shell system . . `[`. -d /var/lib/mongodbscip-shell filesystem . . `/var/lib/mongodb`. ] ; then |
| 129 | sudoscip-shell system . . sudo. rm -rf /var/lib/mongodbscip-shell filesystem . . `/var/lib/mongodb`. |
| 130 | fi |
| 131 | |
| 132 | # ###### Error ############################################################## |
| 133 | else |
| 134 | echoscip-shell system . . echo. >&2 "ERROR: Unsupported database: $1" |
| 135 | exit 1 |
| 136 | fi |