Just making textextractor one of the branches that can be chosen in the scripts. Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
159 lines
4.0 KiB
Bash
Executable File
159 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Info
|
|
|
|
usage() {
|
|
echo "${0} devbranch [devbranch]" 1>&2
|
|
echo "for example: ${0} autocropper" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
# Do we have exactly 1 command-line arguments or not?
|
|
if [ ! ${#} -ge 1 ]; then
|
|
usage
|
|
fi
|
|
|
|
|
|
|
|
# functions
|
|
|
|
stopalldockercontainers() {
|
|
branches=( ${branches[@]/"all"} )
|
|
for branch in ${branches[@]}; do
|
|
dockercontainername="ri"${branch}"devenv"
|
|
|
|
docker stop ${dockercontainername}
|
|
|
|
done
|
|
}
|
|
|
|
|
|
|
|
# actual script
|
|
|
|
realbranches=("app" "autocropper textextractor")
|
|
branches=()
|
|
|
|
for arg in $(seq 1 ${#}); do
|
|
if [[ $(echo ${realbranches[@]} | fgrep -w ${!arg}) ]]; then
|
|
branches+=( ${!arg} )
|
|
else
|
|
echo "${!arg} is not a branch name. The possible branches are: ${realbranches[@]}" 1>&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# echo $(pwd)
|
|
|
|
|
|
# FIND IP AND SET DISPLAY THING FOR X SERVER
|
|
# referenced https://stackoverflow.com/questions/63859293/docker-for-gui-based-environments-on-windows,
|
|
# https://stackoverflow.com/questions/53113171/how-can-i-determine-the-ip-address-from-a-bash-script,
|
|
# and https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
|
|
unameOut="$(uname -s)"
|
|
case "${unameOut}" in
|
|
Linux*) machine=Linux;;
|
|
Darwin*) machine=Mac;;
|
|
CYGWIN*) machine=Cygwin;;
|
|
MINGW*) machine=MinGw;;
|
|
MSYS_NT*) machine=Git;;
|
|
*) machine="UNKNOWN:${unameOut}"
|
|
esac
|
|
|
|
|
|
# FOR DISPLAYING WINDOWS FROM DOCKER CONTAINER,
|
|
# referenced https://cuneyt.aliustaoglu.biz/en/running-gui-applications-in-docker-on-windows-linux-mac-hosts/
|
|
|
|
XSOCK=/tmp/.X11-unix
|
|
XAUTH=/tmp/.docker.xauth
|
|
|
|
case "${machine}" in
|
|
Linux)
|
|
DISPLAYFLAGS="-e DISPLAY -v $XSOCK:$XSOCK"
|
|
OS="Linux"
|
|
;;
|
|
Mac)
|
|
LOCAL_IP=${LOCAL_IP:-`ipconfig getifaddr en0`}
|
|
xhost + ${LOCAL_IP}
|
|
DISPLAY1="${LOCAL_IP}":0
|
|
DISPLAY1="${DISPLAY1## }"
|
|
DISPLAYFLAGS="-e DISPLAY=$DISPLAY1 -v $XSOCK:$XSOCK"
|
|
OS="Mac"
|
|
;;
|
|
*)
|
|
LOCAL_IP=${LOCAL_IP:-`ipconfig.exe | grep -im1 'IPv4 Address' | cut -d ':' -f2`}
|
|
DISPLAY1="${LOCAL_IP}":0.0
|
|
DISPLAY1="${DISPLAY1## }"
|
|
DISPLAYFLAGS="-e DISPLAY="$DISPLAY1
|
|
OS="Windows"
|
|
esac
|
|
|
|
# echo "docker run --rm -it ${DISPLAYFLAGS} aliustaoglu/firefox" #CAN BE DELETE-----------------------------------
|
|
# docker run --rm -it ${DISPLAYFLAGS} aliustaoglu/firefox #CAN BE DELETE-----------------------------------
|
|
|
|
|
|
for branch in ${branches[@]}; do
|
|
dockercontainername="ri"${branch}"devenv"
|
|
imagename=${branch}"indexerenv"
|
|
extrarunflags=""
|
|
case ${branch} in
|
|
"autocropper")
|
|
if [ "$OS" = "Windows" ]; then
|
|
extrarunflags+="--gpus all"
|
|
fi
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
# echo " docker run --rm --mount type=bind,source="$(pwd)"/code,target=/mnt/code -w "//mnt/code" -it --name ${dockercontainername} \
|
|
# ${DISPLAYFLAGS} \
|
|
# --memory=8g --cpus=6 \
|
|
# ${extrarunflags} \
|
|
# ${imagename}"
|
|
|
|
# echo "hi"
|
|
docker run --rm --mount type=bind,source="$(pwd)"/code,target=/mnt/code -w "//mnt/code" -it -d --name "${dockercontainername}" ${DISPLAYFLAGS} \
|
|
--memory=8g --cpus=6 \
|
|
${extrarunflags} ${imagename}
|
|
|
|
done
|
|
|
|
# docker container ls -a
|
|
|
|
branches+=( "all" )
|
|
# echo ${realbranches[@]} | fgrep -w "all"
|
|
|
|
while [ ! ${#branches[@]} -eq 0 ]; do
|
|
echo "Choose docker container to close:"
|
|
select branch in "${branches[@]}"; do
|
|
if [ "${branch}" = "all" ]; then
|
|
stopalldockercontainers
|
|
branches=()
|
|
break
|
|
fi
|
|
# echo $branch
|
|
dockercontainername="ri"${branch}"devenv"
|
|
docker stop ${dockercontainername}
|
|
|
|
branches=( ${branches[@]/$branch} )
|
|
# echo "${branches[@]}"
|
|
|
|
if [ ! -n "$(echo ${realbranches[@]} | fgrep -w "all")" -a ${#branches[@]} -eq 2 ]; then
|
|
branches=( ${branches[@]/"all"} )
|
|
fi
|
|
break
|
|
done
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "${machine}" == "Mac" ]; then
|
|
xhost - ${LOCAL_IP}
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|