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

new task for stopping all containers except traefik

parent cf7ad727
......@@ -23,3 +23,8 @@ task:shell() {
task:docker-compose() {
docker:docker-compose "$@"
}
task:halt:others() {
docker stop $(docker ps -a | grep -v "traefik" | grep -v "CONTAINER" | awk "{print \$1}")
docker rm $(docker ps -a | grep -v "traefik" | grep -v "CONTAINER" | awk "{print \$1}")
}
\ No newline at end of file
#!/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