From 96d04f26ffe4e97c3dfde7dc0486144c92ec51d3 Mon Sep 17 00:00:00 2001 From: Dario Ghunney Ware Date: Tue, 10 Dec 2024 11:10:52 +0000 Subject: [PATCH] #2270 cleanup --- scripts/init_db.sh | 101 --------------------- src/main/resources/settings.yml.template | 1 - src/main/resources/setup_pg_admin_user.sql | 1 + 3 files changed, 1 insertion(+), 102 deletions(-) delete mode 100755 scripts/init_db.sh diff --git a/scripts/init_db.sh b/scripts/init_db.sh deleted file mode 100755 index 4551db2c5cc..00000000000 --- a/scripts/init_db.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# Enable robust error handling -set -o errexit -set -o nounset -set -o pipefail - -# Variables -DB_NAME="stirling_pdf" -DB_USER="admin" -DB_PASSWORD="stirling" -DB_TYPE=${1:-"postgresql"} # Default to PostgreSQL if not provided -DB_HOST="localhost" -DB_PORT="" - -# Check database type and set defaults -case "$DB_TYPE" in - postgresql) - DB_PORT="5432" - ;; - mysql) - DB_PORT="3306" - ;; - oracle) - DB_PORT="1521" - ;; - *) - echo "Unsupported database type: $DB_TYPE" - exit 1 - ;; -esac - -# Function to create PostgreSQL database and user -create_postgres() { - echo "Creating PostgreSQL database '$DB_NAME'..." - - # Check if the database exists - if psql -h "$DB_HOST" -p "$DB_PORT" -U postgres -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then - echo "Database '$DB_NAME' already exists." - else - # Create user and database - psql -h "$DB_HOST" -p "$DB_PORT" -U postgres -c "DO \$$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '$DB_USER') THEN CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASSWORD'; END IF; END \$$;" - createdb -h "$DB_HOST" -p "$DB_PORT" -U postgres --owner="$DB_USER" "$DB_NAME" - echo "Database '$DB_NAME' created successfully with owner '$DB_USER'." - fi -} - -# Function to create MySQL database and user -create_mysql() { - echo "Creating MySQL database '$DB_NAME'..." - - # Check if the database exists - if mysql -h "$DB_HOST" -P "$DB_PORT" -u root -e "SHOW DATABASES LIKE '$DB_NAME';" | grep -qw "$DB_NAME"; then - echo "Database '$DB_NAME' already exists." - else - # Create user and database - mysql -h "$DB_HOST" -P "$DB_PORT" -u root -e "CREATE DATABASE IF NOT EXISTS $DB_NAME;" - mysql -h "$DB_HOST" -P "$DB_PORT" -u root -e "CREATE USER IF NOT EXISTS '$DB_USER'@'%' IDENTIFIED BY '$DB_PASSWORD';" - mysql -h "$DB_HOST" -P "$DB_PORT" -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'%';" - echo "Database '$DB_NAME' created successfully with owner '$DB_USER'." - fi -} - -# Function to create Oracle database and user -create_oracle() { - echo "Creating Oracle database '$DB_NAME'..." - # Check if the user exists - EXISTS=$(sqlplus -s sys/oracle@//"$DB_HOST":"$DB_PORT"/orcl as sysdba <