Created
January 6, 2017 19:46
-
-
Save zack6849/5276e388b7965f66866c7fce9243f0f5 to your computer and use it in GitHub Desktop.
Ngrok - Magento host changer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires curl and jq | |
# Change the scope IDs for your store in the QUERY variable | |
# Requires ngrok to be running | |
echo "Fetching host!" | |
NGROK_HOST=$(curl -s localhost:4040/api/tunnels | jq '.tunnels[0].public_url' | uniq | cut -d '"' -f 2) | |
MYSQL_HOST="localhost" | |
MYSQL_USER="root" | |
MYSQL_PASSWORD="password" | |
MYSQL_DATABASE="magento" | |
MYSQL=$(which mysql) | |
MYSQL_COMMAND="$MYSQL --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST -e " | |
QUERY="$MYSQL_COMMAND \" UPDATE core_config_data SET value='$NGROK_HOST' WHERE (path='web/unsecure/base_url' OR path='web/secure/base_url') AND (scope_id = 0 OR scope_id = 2);\"" | |
QUERY_HOSTS="$MYSQL_COMMAND \" SELECT * FROM core_config_data WHERE path LIKE '%base_url%'; \"" | |
echo "$QUERY" | |
eval "$QUERY" | |
echo "$QUERY_HOSTS" | |
eval "$QUERY_HOSTS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment