forked from frederic-boulanger-cs/cpp-dm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-cpp-dm.sh
More file actions
executable file
·39 lines (35 loc) · 886 Bytes
/
start-cpp-dm.sh
File metadata and controls
executable file
·39 lines (35 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# VSCode server
# Connect to http://localhost:8443/
REPO=fred0cs/
IMAGE=cpp-dm
TAG=2021
PORT=8443
URL=http://localhost:${PORT}
if [ -z "$SUDO_UID" ]
then
# not in sudo
USER_ID=`id -u`
USER_NAME=`id -n -u`
else
# in a sudo script
USER_ID=${SUDO_UID}
USER_NAME=${SUDO_USER}
fi
docker run --rm --detach \
--publish ${PORT}:8443 \
--volume ${PWD}:/config/workspace:rw \
--env USERNAME=${USER_NAME} --env USERID=${USER_ID} \
--name ${IMAGE} \
${REPO}${IMAGE}:${TAG}
sleep 5
if [ -z "$SUDO_UID" ]
then
open -a firefox http://localhost:${PORT} \
|| xdg-open http://localhost:${PORT} \
|| echo "Point your web browser at http://localhost:${PORT}"
else
su ${USER_NAME} -c "open -a firefox http://localhost:${PORT}" \
|| su ${USER_NAME} -c "xdg-open http://localhost:${PORT}" \
|| echo "Point your web browser at http://localhost:${PORT}"
fi