-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootstrap.sh
executable file
·126 lines (103 loc) · 2.76 KB
/
bootstrap.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
##########
# Copyright Unidata 2016 All Rights Reserved
#
# This script is part of the unidata/cloudstream Docker image.
#
# It sets up a VNC session accessible via a webbrowser using noVNC and
# then executes start.sh, if available.
#
# Instructions for use are at https://github.com/Unidata/cloudstream.
#
# Copyright Unidata 2015 http://www.unidata.ucar.edu
##########
set -e
trap "echo TRAPed signal" HUP INT QUIT KILL TERM
###
# If HELP environmental variable is non-empty,
# cat the README file and exit.
#
# Start with checking for the CLOUDSTREAM readme, which is default.
# Then, assuming it will be named README[.md/.txt], cat other
# README file which might have been copied in. Finally, print
# out the version file.
#
###
if [ "x${HELP}" != "x" ]; then
if [ -e "/home/${CUSER}/CLOUDSTREAM_README.md" ]; then
cat "/home/${CUSER}/CLOUDSTREAM_README.md"
fi
echo ""
if [ -e "$README_FILE" ]; then
cat "$README_FILE"
fi
echo ""
if [ "/home/${CUSER}/VERSION.md" ]; then
cat "/home/${CUSER}/VERSION.md"
fi
exit
fi
if [ "x${COPYRIGHT}" != "x" ]; then
if [ -e "/home/${CUSER}/COPYRIGHT_CLOUDSTREAM.md" ]; then
cat "/home/${CUSER}/COPYRIGHT_CLOUDSTREAM.md"
fi
echo ""
if [ -e "${COPYRIGHT_FILE}" ]; then
cat "${COPYRIGHT_FILE}"
fi
exit
fi
###
# Print out the version file.
###
if [ "x${VERSION}" != "x" ]; then
cat VERSION.md
echo ""
exit
fi
###
# Determine if we're using SSL Only.
###
SSLOP=""
if [ "x${SSLONLY}" == "xTRUE" ]; then
SSLOP="--ssl-only"
fi
###
# Remove .x11 lock just in case there is one.
###
sudo rm -rf /tmp/.X1-lock
###
# Set up vnc to use a password if USEPASS is non-empty.
###
if [ "x${USEPASS}" == "x" ]; then
cp /home/${CUSER}/.xinitrc.nopassword /home/${CUSER}/.xinitrc
else
mkdir -p /home/${CUSER}/.vnc
cp /home/${CUSER}/.xinitrc.password /home/${CUSER}/.xinitrc
x11vnc -storepasswd "${USEPASS}" /home/${CUSER}/.vnc/passwd >& /dev/null
fi
export SHARESTRING="-noshared"
if [ "x${SHARED}" == "xTRUE" ]; then
export SHARESTRING="-shared"
fi
xinit -- /usr/bin/Xvfb :1 -screen 0 $SIZEW\x$SIZEH\x$CDEPTH >& /dev/null &
sleep 5
export DISPLAY=localhost:1
##
# Invoke noVNC
##
cd /home/${CUSER}/noVNC/utils
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem -batch >& /dev/null
cd ~
/home/${CUSER}/noVNC/utils/launch.sh ${SSLOP} --vnc 127.0.0.1:5901 >& /dev/null &
printf "\n\n=====================================================================\n"
cat VERSION.md
printf "=====================================================================\n\n"
if [ -f /home/${CUSER}/start.sh ]; then
/home/${CUSER}/start.sh >& /dev/null
fi
echo "Session Running at http://localhost:6080"
echo ""
echo "Press [Return] to exit."
echo ""
read