Skip to content

Instantly share code, notes, and snippets.

@dudymas
Created November 18, 2015 17:33
Show Gist options
  • Save dudymas/90d7acc4174ea1803add to your computer and use it in GitHub Desktop.
Save dudymas/90d7acc4174ea1803add to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ "$(which jq)" == "" ]]; then
echo Please install jq \(i.e. brew install jq \)...
echo jq is used to parse configs.
exit 1
fi
function repoint-config {
MACHINE_CONFIG=$1
NEW_STORE=${2:-$PWD}
OLD_STORE=$(jq -r '.HostOptions.AuthOptions.StorePath' < $MACHINE_CONFIG)
echo Updating $MACHINE_CONFIG
echo Moving $OLD_STORE to $NEW_STORE
sed -i '' "s^$OLD_STORE^$NEW_STORE^g" $MACHINE_CONFIG
}
function repoint-configs {
MACHINE_STORAGE_PATH=${MACHINE_STORAGE_PATH:-$PWD}
for config in $MACHINE_STORAGE_PATH/machines/*/config.json ; do
repoint-config $config $MACHINE_STORAGE_PATH
done
}
repoint-configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment