diff --git a/scripts/check-env.sh b/scripts/check-env.sh new file mode 100755 index 00000000..88a677eb --- /dev/null +++ b/scripts/check-env.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Check if .env has all keys from .env.example +cd "$(dirname "$0")/.." +if [ ! -f .env ]; then echo ".env missing"; exit 1; fi +if [ ! -f .env.example ]; then echo ".env.example missing, cannot compare."; exit 0; fi + +# Extract keys and compare +env_keys=$(cut -d'=' -f1 .env | sort) +ex_keys=$(cut -d'=' -f1 .env.example | sort) + +missing=$(comm -23 <(echo "$ex_keys") <(echo "$env_keys")) +if [ -n "$missing" ]; then + echo "Missing env keys:" + echo "$missing" + exit 1 +fi +echo "All env keys present." diff --git a/scripts/db-optimize.sh b/scripts/db-optimize.sh new file mode 100755 index 00000000..0caaa566 --- /dev/null +++ b/scripts/db-optimize.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Optimize all tables in mariadb-turbo +cd "$(dirname "$0")/.." +[ -f .env ] && source .env +DB_USER=${MARIADB_USER:-cms} +DB_PASS=${MARIADB_PASSWORD:-cms} +DB_NAME=${MARIADB_DATABASE:-habbo} + +echo "Optimizing database tables..." +# Get all tables +tables=$(docker compose exec -T mariadb-turbo mariadb -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "SHOW TABLES" -s) +# Optimize them +for table in $tables; do + echo "Optimizing $table..." + docker compose exec -T mariadb-turbo mariadb -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "OPTIMIZE TABLE $table" +done +echo "Optimization complete." diff --git a/scripts/verify-deploy.sh b/scripts/verify-deploy.sh new file mode 100755 index 00000000..6d33c1ce --- /dev/null +++ b/scripts/verify-deploy.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Verify if CMS is reachable +cd "$(dirname "$0")/.." +echo "Checking health..." +if curl -f http://localhost:3002/api/health > /dev/null 2>&1; then + echo "Success: Service is reachable." +else + echo "Error: Service not reachable." + exit 1 +fi