Initial commit

This commit is contained in:
Kevin Moore 2023-12-12 21:45:56 -05:00
commit 6d03b77cc1
No known key found for this signature in database
GPG key ID: 4AB9F74AEB73DBDD
11 changed files with 263 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 MisterCalvin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

80
README.md Normal file
View file

@ -0,0 +1,80 @@
![Main Window](assets/mainwindow.png)
![Virtual Media](assets/virtualmedia.png)
# Supermicro Java iKVM Viewer Docker
A Docker container for connecting to Supermicro Java based iKVM Viewers, built from [jlesage/docker-baseimage-gui](https://github.com/jlesage/docker-baseimage-gui). No more hunting down old versions of Java, enabling insecure legacy algorithms, or configuring other solutions such as OpenWebStart or IcedTea-Web on multiple computers. Simply start the container, open your browser, and use your KVM viewer. Please see the [Disclaimers & Current Bugs](#disclaimers-&-current-bugs) before using.
### docker compose
```
version: '3.8'
services:
supermicro-java-ikvm:
image: ghcr.io/mistercalvin/supermicro-java-ikvm:latest
container_name: supermicro-java-ikvm
environment:
- TZ: UTC
- KVM_HOST: # IP or Hostname
- KVM_USER: # Your IPMI Username
- KVM_PASS: # Your IPMI Password
- DISPLAY_WIDTH: 1024 # Display Width
- DISPLAY_HEIGHT: 768 # Display Height
ports:
- 5800:5800 # Web UI Port
- 5900:5900 # VNC Port
volumes:
- ./vmedia:/app/vmedia/ # Virtual Media ISO's
- ./screenshots:/app/screenshots/ # Screenshots / Recordings
- supermicro-java-ikvm:/config/ # Persistent Configuration for user preferences
restart: no
volumes:
supermicro-java-ikvm:
name: supermicro-java-ikvm
```
### docker cli
Create a named volume before executing the command below: `docker volume create supermicro-java-ikvm` (this will persist user preferences and iKVM .jar files)
```
docker run -d \
--name=supermicro-java-ikvm \
-e TZ="UTC" \
-e USER_ID="1000" \
-e GROUP_ID="1000" \
-e KVM_HOST="" \
-e KVM_USER="" \
-e KVM_PASS="" \
-e DISPLAY_WIDTH="1024" \
-e DISPLAY_HEIGHT="768" \
-p 5800:5800 \
-p 5900:5900 \
-v ./vmedia:/app/vmedia/ \
-v ./screenshots:/app/screenshots/ \
-v supermicro-java-ikvm:/config/
--restart no \
ghcr.io/mistercalvin/supermicro-java-ikvm:latest
```
Once the container is online you can access the web interface via the default port of `5800`. If you wish to password protect this page take a look [here](https://github.com/jlesage/docker-baseimage-gui#vnc-password) for steps on how to do so.
## User / Group Identifiers
The container allows you to modify the UID & GID of the user (`app`) inside the container. If you would like to know more, please see [this page](https://github.com/jlesage/docker-baseimage-gui#usergroup-ids) for more information on the topic. If you are unsure of what this is I recommend leaving `USER_ID` and `GROUP_ID` at their default values of `1000`, or omitting them from your Docker compose files or run commands.
## Disclaimers & Current Bugs
- The image has additional environment variables you can customize, take a look at [this page](https://github.com/jlesage/docker-baseimage-gui#environment-variables) for more information. I have not tested the container with any variables other than what is defined in this repo; use these at your own risk.
- This container has only been tested with the following hardware and firmware revision: `Supermicro X9DR3-F Motherboard (Nuvoton WPCM450 BMC), BMC Firmware 3.62 [SMT_X9_362.bin]`, and the details for the current iKVM are: `ATEN iKVM Viewer v1.69.21 [KVM__V1.69.39.0x0.jar]`. This may work with other BMC manufacturers, but if you are having issues (or success) please [let me know](https://github.com/MisterCalvin/supermicro-java-ikvm/issues).
- Selecting Español or Korean from Options > Preference > Language Setting will crash the program, and any attempts to reconnect to the Java viewer will fail. To fix this, login to your server's web interface, then navigate to Maintenance > iKVM Reset. If this does not work you can also reboot the IPMI unit by navigating to Maintenance > Unit Reset. Unfortunately I do not have a fix at this time, but the crash does not occur under Windows, and I could successfully switch the language to the aformentioned options albiet through a very convoluted manner with hit or miss reproducibility, which tells me I should be able to track this bug down and release a fix in the future.
- If you are having issues with the UI upon boot, navigate to Options > Preference > Window and uncheck "Auto-resize window." Unfortunately this settings does not persist across reboots, so each time the container is restarted you will need to repeat this.
- Continuing on the previous point: not all user preferences are saved. Hotkeys, Mouse Settings, and Keyboard settings seem to persist, but all other customization options such as mounted Virtual Media or Video Settings will be lost and need to be changed again if the container is restarted.
- If the container crashes due to an error you must run `docker compose down` before bringing the container back up, or if you are modifying any env variables you must do a full `docker compose down && docker compose up` or `docker stop supermicro-java-ikvm`, otherwise the program will not be able to find the Java class necessary to make the iKVM connection. This will be addressed in a future release.
- The container assumes your server's web interface is accessible via port 80 or port 443. If you are using a non-standard port and are having issues connecting you may need to modify the initialization script at `build/rootfs/etc/cont-init.d/50-setup-ikvm.sh`, specifically line 10, `url="https://$KVM_HOST"`.
## Credits
Big thanks to Walter Doekes for their [ipmikvm-tls2020](https://www.osso.nl/blog/2020/supermicro-java-console-redirection-kvm/) script and research, without their work this project would have taken far longer. Thanks to Jocelyn Le Sage for their [docker-baseimage-gui](https://github.com/jlesage/docker-baseimage-gui) project, and to Dominik for the inspiration from their [docker-idrac6](https://github.com/DomiStyle/docker-idrac6) project.

53
build/Dockerfile Normal file
View file

@ -0,0 +1,53 @@
FROM --platform=linux/386 jlesage/baseimage-gui:debian-11-v4
ARG CONTAINER_MAJOR_VERSION=1.0
ARG CONTAINER_MINOR_VERSION=0
COPY assets/icon.png /tmp/icon.png
RUN \
set-cont-env HOME "/app" && \
set-cont-env APP_NAME "Supermicro Java iKVM Viewer" && \
set-cont-env APP_VERSION "1.0" && \
set-cont-env DOCKER_IMAGE_VERSION "${CONTAINER_MAJOR_VERSION}.${CONTAINER_MINOR_VERSION}" && \
set-cont-env DOCKER_IMAGE_PLATFORM "linux/386" && \
APP_ICON_URL=/tmp/icon.png && \
install_app_icon.sh "$APP_ICON_URL"
ARG ZULU_VERSION=zulu8.74.0.17-ca-jre8.0.392-linux_i686
ENV \
KVM_HOST="" \
KVM_USER="" \
KVM_PASS="" \
DISPLAY_WIDTH=1024 \
DISPLAY_HEIGHT=768 \
PATH="${PATH}:/opt/${ZULU_VERSION}/bin"
RUN \
add-pkg curl socat unzip psmisc fontconfig libxrender1 libxtst6 && \
add-pkg --virtual certs ca-certificates && \
mkdir /app && \
curl -O --output-dir /tmp/ https://cdn.azul.com/zulu/bin/${ZULU_VERSION}.tar.gz && \
tar -C /opt/ -xvf /tmp/${ZULU_VERSION}.tar.gz && \
ln -s /opt/${ZULU_VERSION}/bin/unpack200 /usr/local/bin/unpack200 && \
ln -s /opt/${ZULU_VERSION}/bin/java /usr/local/bin/java && \
set-cont-env JAVA_OPTS "-Djava.util.prefs.systemRoot=/config/xdg/config -Djava.util.prefs.userRoot=/config/xdg/config -Duser.home=/app -Djava.library.path=/config/xdg/cache" && \
mkdir -p /app/vmedia && \
mkdir -p /app/screenshots && \
del-pkg certs && \
rm /tmp/${ZULU_VERSION}.tar.gz
COPY rootfs /
EXPOSE 5800 5900
WORKDIR /app
LABEL \
org.opencontainers.image.authors="Kevin Moore" \
org.opencontainers.image.title="Supermicro Java iKVM Viewer" \
org.opencontainers.image.description="A container for connecting to Supermicro Java based iKVM viewers via a web browser" \
org.opencontainers.image.source=https://github.com/MisterCalvin/supermicro-java-ikvm \
org.opencontainers.image.version="${CONTAINER_MAJOR_VERSION}.${CONTAINER_MINOR_VERSION}" \
org.opencontainers.image.licenses=MIT

BIN
build/assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -0,0 +1,75 @@
#!/bin/sh
set -e # Exit immediately if a command exits with a non-zero status
set -u # Treat unset variables as an error
APP_CACHE_DIR=$XDG_CACHE_HOME
get_launch_jnlp() {
fail=1
url="https://$KVM_HOST"
temp=$(mktemp)
if curl --fail -sk --cookie-jar "$temp" -XPOST "$url/cgi/login.cgi" \
--data "name=$KVM_USER&pwd=$KVM_PASS&check=00" -o/dev/null; then
launch_jnlp=$(curl --fail -sk --cookie "$temp" \
"$url/cgi/url_redirect.cgi?url_name=man_ikvm&url_type=jwsk")
test $? -eq 0 && fail=
fi
rm "$temp"
test -z "$fail" && echo "$launch_jnlp"
}
get_username() {
launch_jnlp="$1"
echo "$launch_jnlp" | sed -e '/<argument>/!d' |
sed -e '2!d;s#.*<argument>\([^<]*\)</argument>#\1#'
}
get_password() {
launch_jnlp="$1"
echo "$launch_jnlp" | sed -e '/<argument>/!d' |
sed -e '3!d;s#.*<argument>\([^<]*\)</argument>#\1#'
}
install_ikvm_application() {
launch_jnlp="$1"
destdir="$2"
set -e
codebase=$(
echo "$launch_jnlp" | sed -e '/<jnlp /!d;s/.* codebase="//;s/".*//')
jar=$(
echo "$launch_jnlp" | sed -e '/<jar /!d;s/.* href="//;s/".*//')
linuxlibs=$(
echo "$launch_jnlp" |
sed -e '/<nativelib /!d;/linux.*x86__/!d;s/.* href="//;s/".*//' |
sort -u)
set -x
mkdir -p "$destdir"
cd "$destdir"
for x in $jar $linuxlibs; do
curl -o $x.pack.gz "$codebase$x.pack.gz"
unpack200 $x.pack.gz $x
done
unzip -o liblinux*.jar
rm -rf META-INF
set +x
set +e
}
JNLP=$(get_launch_jnlp "$KVM_HOST" "$KVM_USER" "$KVM_PASS")
test -z "$JNLP" && echo "Failed to get launch.jnlp" >&2 && exit 1
JAR=$(find $APP_CACHE_DIR -name 'iKVM*.jar' | sort | tail -n1)
if ! test -f "$JAR"; then
install_ikvm_application "$JNLP" "$APP_CACHE_DIR"
JAR=$(find $APP_CACHE_DIR -name 'iKVM*.jar' | sort | tail -n1)
if ! ls -l "$JAR"; then
echo "Install failure" >&2
exit 1
fi
fi
echo $JAR >> /etc/cont-env.d/KVM_JAR_FILE
echo $(get_username "$JNLP") >> /etc/cont-env.d/KVM_EPHEMERAL_USERNAME
echo $(get_password "$JNLP") >> /etc/cont-env.d/KVM_EPHEMERAL_PASSWORD

View file

@ -0,0 +1,3 @@
#!/bin/sh
take-ownership /app

3
build/rootfs/startapp.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
exec java $JAVA_OPTS -cp "$(cat /etc/cont-env.d/KVM_JAR_FILE)" tw.com.aten.ikvm.KVMMain $KVM_HOST $(cat /etc/cont-env.d/KVM_EPHEMERAL_USERNAME) $(cat /etc/cont-env.d/KVM_EPHEMERAL_PASSWORD) null 63630 623 2 0 1 5900

27
docker-compose.yml Normal file
View file

@ -0,0 +1,27 @@
version: '3.8'
services:
supermicro-java-ikvm:
image: supermicro-java-ikvm
container_name: supermicro-java-ikvm
build:
context: build
environment:
TZ: ${TZ}
KVM_HOST: ${KVM_HOST} # IP or Hostname
KVM_USER: ${KVM_USER}
KVM_PASS: ${KVM_PASS}
DISPLAY_WIDTH: 1024 # Display Width
DISPLAY_HEIGHT: 768 # Display Height
ports:
- ${WEB_PORT}:5800 # Web UI Port
- ${VNC_PORT}:5900 # VNC Port
volumes:
- ./vmedia:/app/vmedia/ # Virtual Media ISO's
- ./screenshots:/app/screenshots/ # Screenshots / Recordings
- supermicro-java-ikvm:/config/ # Persistent Configuration for user preferences
restart: no
volumes:
supermicro-java-ikvm:
name: supermicro-java-ikvm

BIN
screenshots/mainwindow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB