Commit ab141f9b authored by Eugeni Ostapko's avatar Eugeni Ostapko
Browse files

sh script for stopping all active docker projects by reading the existing yaml config

parent 3e223a90
#!/bin/sh
path=~/Sites/dev
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
for project in $path/*/; do
if [ -e $project/build/config.yml ]; then
eval $(parse_yaml $project/build/config.yml "config_")
if [ "$(docker ps -q -f name=$config_project_key)" ] && [ "$config_project_key" != "traefik" ]; then
echo "\n\n*** Stopping: $config_project_key ***\n"
cd "$project"
b5 halt
fi
fi
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment