2020-02-09 11:18:42 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
2020-02-19 17:45:52 -06:00
|
|
|
showHelp=0
|
|
|
|
showError=0
|
|
|
|
doBuildSystem=0
|
|
|
|
doBuildCoriolis=0
|
|
|
|
doBuildBash=0
|
|
|
|
doBuild=0
|
|
|
|
doRun=0
|
|
|
|
doRemove=0
|
2020-02-09 11:18:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "./docker-conf.sh" ]; then
|
|
|
|
echo "[ERROR] Missing \"./docker-conf.sh\"."
|
|
|
|
echo " (wd:\"`pwd`\")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
. "./docker-conf.sh"
|
2020-02-19 17:45:52 -06:00
|
|
|
dockerImages="${systemImage},${coriolisImage},${bashImage}"
|
2020-02-09 11:18:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
2020-02-19 17:45:52 -06:00
|
|
|
--help) showHelp=1;;
|
|
|
|
--build-system) doBuildSystem=1;;
|
|
|
|
--build-coriolis) doBuildCoriolis=1;;
|
|
|
|
--build-bash) doBuildBash=1;;
|
|
|
|
--run) doRun=1;;
|
|
|
|
--remove) doRemove=1;;
|
2020-02-09 11:18:42 -06:00
|
|
|
-*) NB=2; CH=`echo $1 | cut -c$NB`
|
|
|
|
while [ "$CH" != "" ]; do
|
|
|
|
case $CH in
|
|
|
|
h) showHelp=1;;
|
2020-02-19 17:45:52 -06:00
|
|
|
s) doBuildSystem=1;;
|
|
|
|
c) doBuildCoriolis=1;;
|
|
|
|
b) doBuildBash=1;;
|
2020-02-09 11:18:42 -06:00
|
|
|
r) doRun=1;;
|
|
|
|
*) showError=1; badOption="$1";;
|
|
|
|
esac
|
|
|
|
NB=`expr $NB + 1`
|
|
|
|
CH=`echo $1 | cut -c$NB`
|
|
|
|
done;;
|
|
|
|
*) showError=1; badOption="$1";;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${showError} -ne 0 ]; then
|
|
|
|
echo "[ERROR] Unknown argument \"${badOption}\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${showHelp} -ne 0 ]; then
|
|
|
|
echo "Usage: ./manager.sh [options]"
|
|
|
|
echo "Options:"
|
2020-02-19 17:45:52 -06:00
|
|
|
echo " * [-h|--help]: Print this help."
|
|
|
|
echo " * [-s|--build-system]: Rebuild the whole OS image."
|
|
|
|
echo " * [-c|--build-coriolis]: Rebuild the Coriolis image. It will remove the previous"
|
|
|
|
echo " images (${dockerImages})."
|
|
|
|
echo " * [-b|--build-bash]: Rebuild the Bash (shell) image. It will remove the previous"
|
|
|
|
echo " image (${bashImage})."
|
|
|
|
echo " * [-r|--run]: Recompile Alliance, Coriolis & perform benchs."
|
|
|
|
echo " * [--remove]: Remove container(s) & image(s)."
|
2020-02-09 11:18:42 -06:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-02-19 17:45:52 -06:00
|
|
|
if [ ${doBuildSystem} -ne 0 ]; then
|
|
|
|
doBuildBash=1
|
|
|
|
doBuildCoriolis=1
|
|
|
|
doBuild=1
|
|
|
|
doRemove=1
|
2020-02-09 11:18:42 -06:00
|
|
|
fi
|
|
|
|
|
2020-02-19 17:45:52 -06:00
|
|
|
if [ ${doBuildCoriolis} -ne 0 ]; then
|
|
|
|
doBuildBash=1
|
|
|
|
doBuild=1
|
|
|
|
doRemove=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${doBuildBash} -ne 0 ]; then
|
|
|
|
doBuild=1
|
|
|
|
doRemove=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${doRemove} -ne 0 ]; then
|
|
|
|
if [ ${doBuildBash} -ne 0 ]; then
|
|
|
|
echo "Removing \"${bashImage}\" docker container."
|
|
|
|
docker rm ${bashImage}
|
|
|
|
docker rmi ${bashImage}
|
|
|
|
fi
|
2020-02-09 11:18:42 -06:00
|
|
|
|
2020-02-19 17:45:52 -06:00
|
|
|
if [ ${doBuildCoriolis} -ne 0 ]; then
|
|
|
|
echo "Removing \"${coriolisImage}\" docker image."
|
|
|
|
docker rm ${coriolisImage}
|
|
|
|
docker rmi ${coriolisImage}
|
|
|
|
fi
|
2020-02-09 11:18:42 -06:00
|
|
|
|
|
|
|
if [ ${doBuildSystem} -ne 0 ]; then
|
|
|
|
echo "Removing \"${systemImage}\" docker image."
|
|
|
|
docker rm ${systemImage}
|
|
|
|
docker rmi ${systemImage}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${doBuild} -ne 0 ]; then
|
|
|
|
echo "Synching Alliance & Coriolis builder scripts."
|
|
|
|
cp ../../socInstaller.py ./root
|
2020-02-19 17:45:52 -06:00
|
|
|
cp ../../dot.bashrc ./root
|
2020-02-09 11:18:42 -06:00
|
|
|
|
|
|
|
if [ ${doBuildSystem} -ne 0 ]; then
|
|
|
|
echo "Build \"${systemImage}\" docker image."
|
|
|
|
docker build -f Dockerfile.system -t ${systemImage} .
|
|
|
|
fi
|
|
|
|
|
2020-02-19 17:45:52 -06:00
|
|
|
if [ ${doBuildCoriolis} -ne 0 ]; then
|
|
|
|
echo "Build \"${coriolisImage}\" docker image."
|
|
|
|
docker build -f Dockerfile.coriolis -t ${coriolisImage} .
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${doBuildCoriolis} -ne 0 ]; then
|
|
|
|
echo "Build \"${bashImage}\" docker image."
|
|
|
|
docker build -f Dockerfile.bash -t ${bashImage} .
|
|
|
|
fi
|
2020-02-09 11:18:42 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${doRun} -ne 0 ]; then
|
2020-02-19 17:45:52 -06:00
|
|
|
docker run --rm --net=host -e DISPLAY=:0 -ti --name ${bashImage} ${bashImage}
|
2020-02-09 11:18:42 -06:00
|
|
|
fi
|