Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple spelling fix #10

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:14.04
#FROM ubuntu:14.04
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV HOME /root

RUN apt-get update && apt-get install -y --force-yes --no-install-recommends \
supervisor xinetd x11vnc xvfb xdotool x11-utils curl unzip openjdk-7-jre \
x11-xserver-utils xmlstarlet iptables xloadimage \
&& apt-get autoclean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -yyq --no-install-recommends \
supervisor x11vnc xvfb xdotool x11-utils curl unzip openjdk-8-jre \
x11-xserver-utils xmlstarlet iptables xloadimage git python3-pip \
&& pip3 install numpy \
&& apt-get autoclean && apt-get autoremove && rm -rf /var/lib/apt/lists/* \
|| exit ${?}

ADD etc /etc
ADD opt /opt

RUN tar xfz /opt/kvm-console/noVNC.tgz -C /opt/kvm-console

# The delay (in seconds) between connections before the container is terminated
ENV CONSOLE_TTL "3600"

Expand All @@ -36,14 +41,23 @@ ENV SPLASH_IMAGE ""
# Screen size to show until we get the application working
ENV SPLASH_SIZE ""

# The VNC password to use
ENV VNC_PASSWORD "no-password"

# The username to use when connecting to the BMC
ENV IPMI_USERNAME "ADMIN"
# The password to use when connecting to the BMC
ENV IPMI_PASSWORD "ADMIN"

# The noVNC inactivity timeout (in seconds)
ENV INACTIVITY_TIMEOUT 1800

# The address of the BMC to connect (MANDATORY)
# Define with `docker run <image_name> -e IPMI_ADDRESS=<address>`
#ENV IPMI_ADDRESS "192.0.2.10"

EXPOSE 5900
HEALTHCHECK --interval=10s --retries=3 --start-period=30s CMD /opt/kvm-console/bin/activity-watcher.sh

#EXPOSE 5900
EXPOSE 8080
ENTRYPOINT ["/opt/kvm-console/bin/startup.sh"]
43 changes: 33 additions & 10 deletions console-supermicro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,46 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_console_supermicro() {
if [ 0 = ${#} ] || [ 3 -lt ${#} ] ; then
echo 'usage: console-supermicro.sh <host> [username] [password]'
return
fi
docker build -t internap/kvm-console-supermicro $(dirname ${0}) || return ${?}

docker build -t internap/kvm-console-supermicro $(dirname ${0})
id=$(docker run -P -d \
-e IPMI_ADDRESS=${1} \
-e IPMI_USERNAME=${2-ADMIN} \
-e IPMI_PASSWORD=${3-ADMIN} \
internap/kvm-console-supermicro)
if [ "" = "${id}" ] ; then
echo could not get container id:
docker ps | grep internap/kvm-console-supermicro
return 1
fi

id=$(docker run -P -d \
-e IPMI_ADDRESS=${1} \
-e IPMI_USERNAME=${2-ADMIN} \
-e IPMI_PASSWORD=${3-ADMIN} \
internap/kvm-console-supermicro)
sleep 2

sleep 2
vncviewer $(docker port $id | cut -d ' ' -f 3)
docker rm --force $id
local port=$( docker port $id | sed 's,.*:,,' )
local url="http://localhost:${port}/vnc.html?host=localhost&port=${port}&autoconnect=true&password=no-password"
echo ${url} | sed 's,.,-,g'
echo ${url}
echo ${url} | sed 's,.,-,g'

echo hit enter to end me
read

docker rm --force ${id}

echo bye
}

_console_supermicro ${*}
5 changes: 2 additions & 3 deletions etc/supervisor/conf.d/idle-timeout.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ priority=1
directory=/
command=/bin/bash -c '[ "$CONSOLE_TTL" ] && sleep $CONSOLE_TTL && supervisorctl shutdown'
user=root
autostart=true
autostart=false
stopsignal=KILL
stdout_logfile=/var/log/idle-timeout.log
stdout_logfile=/var/log/supervisor/idle-timeout.log
redirect_stderr=true

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

[program:xinetd]
priority=5
directory=/
command=/usr/sbin/xinetd -dontfork
user=root
autostart=true
[program:novnc]
command=/opt/kvm-console/bin/novnc.sh
autorestart=true
stopsignal=QUIT
environment=HOME="/home/kvm-console"
stdout_logfile=/var/log/xinetd.log
autostart=true
priority=4
user=root
stdout_logfile=/var/log/supervisor/novnc.log
redirect_stderr=true

5 changes: 2 additions & 3 deletions etc/supervisor/conf.d/viewer-app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ priority=15
directory=/home/kvm-console
command=/opt/kvm-console/bin/viewer-app.sh
user=kvm-console
autostart=false
autostart=true
autorestart=true
stopsignal=QUIT
environment=DISPLAY=":1",HOME="/home/kvm-console"
stdout_logfile=/var/log/viewer-app.log
stdout_logfile=/var/log/supervisor/viewer-app.log
redirect_stderr=true

6 changes: 3 additions & 3 deletions etc/supervisor/conf.d/vnc-export-app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ priority=16
directory=/home/kvm-console
command=/opt/kvm-console/bin/vnc-export-app.sh
user=kvm-console
autostart=false
autorestart=true
autostart=true
autorestart=false
stopsignal=QUIT
environment=DISPLAY=":1",HOME="/home/kvm-console"
stdout_logfile=/var/log/vnc-export-app.log
stdout_logfile=/var/log/supervisor/vnc-export-app.log
redirect_stderr=true
stopsignal=KILL

7 changes: 3 additions & 4 deletions etc/supervisor/conf.d/vnc-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
priority=20
directory=/
command=/opt/kvm-console/bin/vnc-server.sh
user=kvm-console
autostart=false
user=root
autostart=true
autorestart=true
stopsignal=QUIT
environment=DISPLAY=":1",HOME="/home/kvm-console"
stdout_logfile=/var/log/vnc-server.log
stdout_logfile=/var/log/supervisor/vnc-server.log
redirect_stderr=true

5 changes: 2 additions & 3 deletions etc/supervisor/conf.d/x11-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ priority=10
directory=/
command=/usr/bin/Xvfb :1 -screen 0 1200x800x16 -dpms
user=kvm-console
autostart=false
autostart=true
autorestart=true
stopsignal=QUIT
stdout_logfile=/var/log/x11-server.log
stdout_logfile=/var/log/supervisor/x11-server.log
redirect_stderr=true

24 changes: 0 additions & 24 deletions etc/xinetd.conf

This file was deleted.

37 changes: 37 additions & 0 deletions opt/kvm-console/bin/activity-watcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

export EXPRESSION="listener exit due to --idle-timeout"
export LOG_FILE="/var/log/supervisor/novnc.log"

_activity_watcher_main() {
local status=0

if [ -f "${LOG_FILE}" ] ; then
local idle_count=$( grep -c "${EXPRESSION}" "${LOG_FILE}" ) || return ${?}
if [ "0" = "${idle_count}" ] ; then
_activity_watcher_out "novnc is running"
else
_activity_watcher_out "novnc idled out."
status=${idle_count}
fi
else
_activity_watcher_out "novnc log to watch"
fi

# may need see uptime or check the log...
local java_count=$( ps -ef | grep -v grep | grep -c 'java ' )
if [ "0" = "${java_count}" ] ; then
_activity_watcher_out "java is not running"
let status=${status}+1000
else
_activity_watcher_out "java is running...."
fi

return ${status}
}

_activity_watcher_out() {
echo -n "${*} ; "
}

_activity_watcher_main ${*}
42 changes: 0 additions & 42 deletions opt/kvm-console/bin/connection-handler.sh

This file was deleted.

38 changes: 38 additions & 0 deletions opt/kvm-console/bin/novnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

export DIRECTORY=/opt/kvm-console/noVNC
export COMMAND="${DIRECTORY}/utils/launch.sh"

export LISTEN_PORT=8080
export VNC_URI="localhost:5900"
export VNC_TIMEOUT=${INACTIVITY_TIMEOUT-1800}

_novnc_main() {
cd ${DIRECTORY} || return {?}

if [ -f /certificate.pem ] ; then
echo certificate found, starting securely
_novnc_tls
else
echo no certificate found, starting insecurely
_novnc_basic
fi
}

_novnc_basic() {
${COMMAND} --web ${DIRECTORY} --listen ${LISTEN_PORT} --vnc ${VNC_URI} --idle-timeout ${VNC_TIMEOUT}
}

_novnc_tls() {
cat /certificate.pem /certificate-authority.pem > /tmp/combined.pem
${COMMAND} \
--listen ${LISTEN_PORT} \
--vnc ${VNC_URI} \
--cert /tmp/combined.pem \
--key /private-key.key \
--ssl-only \
--web ${DIRECTORY}
--idle-timeout ${VNC_TIMEOUT}
}

_novnc_main ${*}
2 changes: 2 additions & 0 deletions opt/kvm-console/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# limitations under the License.

id -u kvm-console &>/dev/null || useradd --create-home --shell /bin/bash --user-group kvm-console
chown -R kvm-console.kvm-console /opt/noVNC*

exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
Loading