receipt_indexer/run.sh
Ethan Wellenreiter 7426d0a90c Setting script permissions
Making the run and setup scripts executable so that when I clone
they are executable right away.

Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
2023-09-15 21:41:48 -04:00

59 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# 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"
;;
Mac)
LOCAL_IP=${LOCAL_IP:-`ipconfig getifaddr en0`}
xhost + ${LOCAL_IP}
DISPLAY1="${LOCAL_IP}":0
DISPLAY1="${DISPLAY1## }"
DISPLAYFLAGS="-e DISPLAY=$DISPLAY1 -v $XSOCK:$XSOCK"
;;
*)
LOCAL_IP=${LOCAL_IP:-`ipconfig.exe | grep -im1 'IPv4 Address' | cut -d ':' -f2`}
DISPLAY1="${LOCAL_IP}":0.0
DISPLAY1="${DISPLAY1## }"
DISPLAYFLAGS="-e DISPLAY="$DISPLAY1
esac
# echo "docker run --rm -it ${DISPLAYFLAGS} aliustaoglu/firefox" #CAN BE DELETE-----------------------------------
# docker run --rm -it ${DISPLAYFLAGS} aliustaoglu/firefox #CAN BE DELETE-----------------------------------
docker run --rm --mount type=bind,source="$(pwd)"/code,target=/mnt/code -w "//mnt/code" -it --name receiptindexerdevenv \
${DISPLAYFLAGS} \
--gpus all \
indexerenv
if [ "${machine}" == "Mac" ]; then
xhost - ${LOCAL_IP}
fi