Skip to content

Instantly share code, notes, and snippets.

@AtsushiA
Created November 29, 2015 13:46
Show Gist options
  • Save AtsushiA/f27db70657dfcb8d0e82 to your computer and use it in GitHub Desktop.
Save AtsushiA/f27db70657dfcb8d0e82 to your computer and use it in GitHub Desktop.
#!/bin/bash
## Wocker - http://wckr.github.io
## Sctipt to Switch Container (STOP active Container & START other Container)
## switch.sh [Container Name]
#SET Options
shopt -s expand_aliases
source ~/.bash_profile
## Check Value
#echo Value Count $#
if [ $# -ne 1 ]; then
echo "Please Set Container Name!"
echo "switch.sh [Container NAME]"
exit 1
fi
#CHECK wocker ps
if [ `wocker ps | wc -l` -eq 2 ]; then
C_NAME=`wocker ps | awk '{field = $NF } END {print field }'`
if [ ${C_NAME} == $1 ]; then
echo "Same Container [Exit]"
exit 2
fi
echo "----- Active Container -----"
wocker stop ${C_NAME}
echo "----- Switch to -----"
else
echo "No Active Container"
fi
#START wocker Container
wocker start $1
if [ $? != 0 ]; then
echo "Error : Wrong Set Container Name!!"
else
echo "Done."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment