2014-02-02 05:52:53 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
|
|
|
|
|
|
|
SOURCE=$(pwd)/android
|
2014-07-14 01:30:56 -04:00
|
|
|
CONTAINER_HOME=/home/cmbuild
|
2014-02-02 17:55:33 -05:00
|
|
|
CONTAINER=cyanogenmod
|
|
|
|
REPOSITORY=stucki/cyanogenmod
|
2014-02-02 05:52:53 -05:00
|
|
|
|
2014-07-14 01:30:56 -04:00
|
|
|
# Create a shared folder which will be used as working directory if it
|
|
|
|
# does not already exists.
|
|
|
|
mkdir -p $SOURCE
|
2014-02-02 05:52:53 -05:00
|
|
|
|
2014-07-14 01:30:56 -04:00
|
|
|
# Build image if needed
|
|
|
|
IMAGE_EXISTS=$(docker images -q $REPOSITORY)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "docker command not found"
|
|
|
|
exit $?
|
|
|
|
elif [[ -z $IMAGE_EXISTS ]]; then
|
|
|
|
docker build --no-cache --rm -t $REPOSITORY .
|
|
|
|
fi
|
|
|
|
|
|
|
|
# With the given name $CONTAINER, reconnect to running container, start
|
|
|
|
# an existing/stopped container or run a new one if one does not exists.
|
|
|
|
IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null)
|
|
|
|
if [[ $IS_RUNNING == "true" ]]; then
|
|
|
|
docker attach $CONTAINER
|
|
|
|
elif [[ $IS_RUNNING == "false" ]]; then
|
|
|
|
docker start -i $CONTAINER
|
|
|
|
else
|
|
|
|
docker run -v $SOURCE:$CONTAINER_HOME/android -i -t --name $CONTAINER $REPOSITORY sh -c "screen -s /bin/bash";
|
|
|
|
fi
|
2014-02-02 05:52:53 -05:00
|
|
|
|
|
|
|
exit $?
|