Add script to migrate existing Ghost config

- Ghost requires env variables to be in a special `__` format which is hard to construct manually
- This script automates that for ease of migration
- Currently doesn't meet our ESLint rules in the slightest so will need tweaking
This commit is contained in:
James Loh
2025-06-27 17:46:07 +10:00
parent 7a7f41b82c
commit 4251163b73
2 changed files with 160 additions and 1 deletions

View File

@@ -109,8 +109,25 @@ echo " MySQL is ready!"
echo "Importing database..."
docker compose exec -T db sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" $MYSQL_DATABASE' < "${PWD}/data/ghost_import.sql"
echo "The migrator will now try and import your existing configuration: "
# Run the config-to-env.js script
node "${PWD}/scripts/config-to-env.js" "${current_location}/config.production.json"
read -rp 'Are you happy with the configuration? [y/n]: ' confirm
case "$confirm" in
[yY][eE][sS]|[yY])
echo "Adding configuration to .env..."
node "${PWD}/scripts/config-to-env.js" "${current_location}/config.production.json" >> "${PWD}/.env"
;;
*)
echo "Skipping, you can manually add the configuration to .env later"
echo "Note: Mail configuration is not imported, if you send email you will need to set it up manually"
;;
esac
# Starting Ghost container
echo "Starting Ghost and containers..."
echo "Starting Ghost..."
docker compose up ghost -d
read -rp 'Would you like to start Caddy? This will stop your existing Nginx installation. [y/n]: ' confirm