minecraft-server-anywhere/script/search-replace-passwords

65 lines
5.2 KiB
Bash

#!/bin/bash
# Change to Project Directory
cd "$(dirname "$0")/.."
# Search and replace change-me-password-root-db
ROOT_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find . -type f -name "docker-compose.yml" -exec sed -i -e 's/change-me-password-root-db/'$ROOT_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-floodgate-db
FLOODGATE_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-floodgate-db/'$FLOODGATE_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-floodgate-db/'$FLOODGATE_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-floodgate-db/'$FLOODGATE_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-floodgate-db/'$FLOODGATE_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-floodgate-db/'$FLOODGATE_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-advancedban-db
ADVANCEDBAN_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-advancedban-db/'$ADVANCEDBAN_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-advancedban-db/'$ADVANCEDBAN_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-advancedban-db/'$ADVANCEDBAN_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-advancedban-db/'$ADVANCEDBAN_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-advancedban-db/'$ADVANCEDBAN_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-luckperms-db
LUCKPERMS_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-luckperms-db/'$LUCKPERMS_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-luckperms-db/'$LUCKPERMS_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-luckperms-db/'$LUCKPERMS_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-luckperms-db/'$LUCKPERMS_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-luckperms-db/'$LUCKPERMS_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-btm-db
BTM_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-btm-db/'$BTM_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-btm-db/'$BTM_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-btm-db/'$BTM_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-btm-db/'$BTM_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-btm-db/'$BTM_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-plot-db
PLOT_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-plot-db/'$PLOT_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-plot-db/'$PLOT_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-plot-db/'$PLOT_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-plot-db/'$PLOT_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-plot-db/'$PLOT_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-rewards-db
REWARDS_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-rewards-db/'$REWARDS_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-rewards-db/'$REWARDS_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-rewards-db/'$REWARDS_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-rewards-db/'$REWARDS_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-rewards-db/'$REWARDS_DB_PASSWORD'/g' {} \;
# Search and replace change-me-password-economy-db
ECONOMY_DB_PASSWORD=$(cat /dev/urandom | tr -dc A-Za-z0-9 | fold -w ${1:-30} | head -n 1)
find ./database -type f -name "*" -exec sed -i -e 's/change-me-password-economy-db/'$ECONOMY_DB_PASSWORD'/g' {} \;
find ./login -type f -name "*" -exec sed -i -e 's/change-me-password-economy-db/'$ECONOMY_DB_PASSWORD'/g' {} \;
find ./proxy -type f -name "*" -exec sed -i -e 's/change-me-password-economy-db/'$ECONOMY_DB_PASSWORD'/g' {} \;
find ./survival -type f -name "*" -exec sed -i -e 's/change-me-password-economy-db/'$ECONOMY_DB_PASSWORD'/g' {} \;
find ./main -type f -name "*" -exec sed -i -e 's/change-me-password-economy-db/'$ECONOMY_DB_PASSWORD'/g' {} \;