1
0
mirror of https://github.com/stucki/docker-lineageos synced 2024-12-19 17:12:29 -05:00

Merge pull request #35 from stucki/bash-improvements

Bash improvements
This commit is contained in:
Michael Stucki 2017-04-22 01:02:10 +02:00 committed by GitHub
commit 75c8df9c9e

21
run.sh
View File

@ -1,15 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
set -euo pipefail
cd $(dirname $0) cd $(dirname $0)
if [[ $OSTYPE == "darwin"* ]]; then SOURCE=$(pwd)/android
SOURCE=$(stat -f %N $(pwd)/android) CCACHE=$(pwd)/ccache
CCACHE=$(stat -f %N $(pwd)/ccache)
else
SOURCE=$(readlink -f $(pwd)/android)
CCACHE=$(readlink -f $(pwd)/ccache)
fi
CONTAINER_HOME=/home/build CONTAINER_HOME=/home/build
CONTAINER=lineageos CONTAINER=lineageos
REPOSITORY=stucki/lineageos REPOSITORY=stucki/lineageos
@ -51,19 +47,14 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
USERID=$(id -u) USERID=$(id -u)
GROUPID=$(id -g) GROUPID=$(id -g)
docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID . docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID .
OK=$?
# After successful build, delete existing containers # After successful build, delete existing containers
IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null)
if [[ $OK -eq 0 ]] && [[ -n "$IS_EXISTING" ]]; then if [[ -n $IS_EXISTING ]]; then
docker rm $CONTAINER docker rm $CONTAINER
fi fi
fi fi
if [[ $OK -ne 0 ]]; then
exit 1
fi
# With the given name $CONTAINER, reconnect to running container, start # With the given name $CONTAINER, reconnect to running container, start
# an existing/stopped container or run a new one if one does not exist. # an existing/stopped container or run a new one if one does not exist.
IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null) IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null)