Skip to content

Instantly share code, notes, and snippets.

@mrunalp
Created September 12, 2012 00:13
Show Gist options
  • Save mrunalp/3703188 to your computer and use it in GitHub Desktop.
Save mrunalp/3703188 to your computer and use it in GitHub Desktop.
Detect env vars to rid of under the current cart directory
#!/bin/bash
# Arguments
whitelist=$@
# Constants
repo_root=/opt/myrepos
# Stolen from util
function convert_cart_name_to_namespace_id {
echo $1 | sed 's/-//g' | sed 's/[^a-zA-Z_]*$//g' | tr '[a-z]' '[A-Z]'
}
function detect () {
cart_name=$1
cart_ns=$(convert_cart_name_to_namespace_id ${cart_name})
patterns=(
"OPENSHIFT_${cart_ns}_CART_DIR"
"OPENSHIFT_${cart_ns}_RUNTIME_DIR"
"OPENSHIFT_${cart_ns}_RUN_DIR"
"OPENSHIFT_${cart_ns}_CTL_SCRIPT"
"OPENSHIFT_${cart_ns}_TMP_DIR"
"OPENSHIFT_GEAR_NAME"
"_GEAR_DIR"
"_GEAR_TYPE"
"_CTL_"
"DUMP"
"RESTORE"
"EMBEDDED"
"rm_app_dir"
)
for pattern in ${patterns[@]}; do
#echo "Searching for ${pattern}..."
echo "=== $pattern ==="
grep --color -re "${pattern}" *
done
}
cart_name=$(basename `pwd`)
echo "=== Scanning ${cart_name} ==="
detect $cart_name
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment