woocommerce-paypal-payments/.ddev/bin/share
2026-02-26 11:00:04 +02:00

32 lines
854 B
Bash
Executable file

#!/usr/bin/env bash
pkill -f ngrok 2>/dev/null || true
PROJECT_HOST=$(ddev describe -j | jq -r '.raw.hostnames[0]')
ddev share >/dev/null &
ngrok-url(){
curl -s localhost:4040/api/tunnels | jq -r .tunnels[0].public_url | awk -F'^http[s]?://' '{print $2}'
}
wp-replace(){
echo "Replacing ${1} with ${2}"
ddev wp search-replace "${1}" "${2}" --all-tables --precise --recurse-objects
}
kill-ngrok(){
echo "Killing ngrok process"
pkill -f ngrok
wp-replace "${NGROK_HOST}" "${PROJECT_HOST}"
}
echo "ngrok started"
echo "Waiting a few seconds for the service to come up"
sleep 3
NGROK_HOST=$(ngrok-url)
wp-replace "${PROJECT_HOST}" "${NGROK_HOST}"
echo "Your site is now reachable at https://${NGROK_HOST}"
echo "ctrl-c to stop sharing and revert database changes"
trap kill-ngrok INT
while pgrep -f ngrok >/dev/null 2>&1; do
sleep 1
done