docker-idrac6/startapp.sh

134 lines
3.3 KiB
Bash
Raw Normal View History

2018-04-05 15:42:34 +02:00
#!/bin/sh
2018-12-21 10:58:39 +01:00
GREEN='\033[0;32m'
2018-04-05 15:42:34 +02:00
RED='\033[0;31m'
NC='\033[0m'
echo "Starting"
2020-01-08 13:05:23 +01:00
if [ -f "/run/secrets/idrac_host" ]; then
echo "Using Docker secret for IDRAC_HOST"
IDRAC_HOST="$(cat /run/secrets/idrac_host)"
fi
if [ -f "/run/secrets/idrac_port" ]; then
echo "Using Docker secret for IDRAC_PORT"
IDRAC_PORT="$(cat /run/secrets/idrac_port)"
fi
if [ -f "/run/secrets/idrac_user" ]; then
echo "Using Docker secret for IDRAC_USER"
IDRAC_USER="$(cat /run/secrets/idrac_user)"
fi
if [ -f "/run/secrets/idrac_password" ]; then
echo "Using Docker secret for IDRAC_PASSWORD"
IDRAC_PASSWORD="$(cat /run/secrets/idrac_password)"
fi
2024-03-25 17:45:59 +01:00
CURL_OPTS=""
JAVA_OPTS=""
if [ -n "${SOCKS_PROXY_HOST}" ]; then
CURL_OPTS="$CURL_OPTS -x socks5://$SOCKS_PROXY_HOST:$SOCKS_PROXY_PORT"
JAVA_OPTS="-DsocksProxyHost=$SOCKS_PROXY_HOST -DsocksProxyPort=$SOCKS_PROXY_PORT"
fi
2018-04-05 15:42:34 +02:00
if [ -z "${IDRAC_HOST}" ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 1
fi
2018-11-19 15:49:34 +01:00
if [ -z "${IDRAC_PORT}" ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Please set a proper idrac port with IDRAC_PORT${NC}"
2018-11-19 15:49:34 +01:00
sleep 2
exit 1
fi
2018-04-05 15:42:34 +02:00
if [ -z "${IDRAC_USER}" ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Please set a proper idrac user with IDRAC_USER${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 1
fi
if [ -z "${IDRAC_PASSWORD}" ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Please set a proper idrac password with IDRAC_PASSWORD${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 1
fi
echo "Environment ok"
cd /app
2018-12-21 10:58:39 +01:00
if [ ! -d "lib" ]; then
echo "Creating library folder"
mkdir lib
fi
2018-04-05 15:42:34 +02:00
if [ ! -f avctKVM.jar ]; then
2018-12-21 10:58:39 +01:00
echo "Downloading avctKVM"
2024-03-25 17:45:59 +01:00
curl $CURL_OPTS -o avctKVM.jar https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctKVM.jar -k --ciphers 'DEFAULT:!DH'
2018-04-05 15:42:34 +02:00
if [ ! $? -eq 0 ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Failed to download avctKVM.jar, please check your settings${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 2
fi
fi
if [ ! -f lib/avctKVMIOLinux64.jar ]; then
2018-12-21 10:58:39 +01:00
echo "Downloading avctKVMIOLinux64"
2024-03-25 17:45:59 +01:00
curl $CURL_OPTS -o lib/avctKVMIOLinux64.jar https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctKVMIOLinux64.jar -k --ciphers 'DEFAULT:!DH'
2018-04-05 15:42:34 +02:00
if [ ! $? -eq 0 ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Failed to download avctKVMIOLinux64.jar, please check your settings${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 2
fi
fi
if [ ! -f lib/avctVMLinux64.jar ]; then
2018-12-21 10:58:39 +01:00
echo "Downloading avctVMLinux64"
2024-03-25 17:45:59 +01:00
curl $CURL_OPTS -o lib/avctVMLinux64.jar https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctVMLinux64.jar -k --ciphers 'DEFAULT:!DH'
2018-04-05 15:42:34 +02:00
if [ ! $? -eq 0 ]; then
2018-12-21 10:58:39 +01:00
echo "${RED}Failed to download avctVMLinux64.jar, please check your settings${NC}"
2018-04-05 15:42:34 +02:00
sleep 2
exit 2
fi
fi
2018-12-21 10:58:39 +01:00
cd lib
if [ ! -f lib/avctKVMIOLinux64.so ]; then
echo "Extracting avctKVMIOLinux64"
jar -xf avctKVMIOLinux64.jar
fi
if [ ! -f lib/avctVMLinux64.so ]; then
echo "Extracting avctVMLinux64"
jar -xf avctVMLinux64.jar
fi
cd /app
echo "${GREEN}Initialization complete, starting virtual console${NC}"
2019-04-02 13:49:15 +02:00
if [ -n "$IDRAC_KEYCODE_HACK" ]; then
2019-04-02 13:17:32 +02:00
echo "Enabling keycode hack"
export LD_PRELOAD=/keycode-hack.so
fi
2024-03-25 17:45:59 +01:00
exec java $JAVA_OPTS -cp avctKVM.jar -Djava.library.path="./lib" com.avocent.idrac.kvm.Main ip=${IDRAC_HOST} kmport=5900 vport=5900 user=${IDRAC_USER} passwd=${IDRAC_PASSWORD} apcp=1 version=2 vmprivilege=true "helpurl=https://${IDRAC_HOST}:443/help/contents.html" &
2019-04-02 13:17:32 +02:00
2022-03-01 04:14:42 +01:00
# If an iso exists at the specified location, mount it
[ -f "/vmedia/$VIRTUAL_ISO" ] && /mountiso.sh
2024-03-25 17:45:59 +01:00
wait