-
Notifications
You must be signed in to change notification settings - Fork 147
/
startapp.sh
125 lines (93 loc) · 3.05 KB
/
startapp.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
#!/bin/sh
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
echo "Starting"
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
if [ -z "${IDRAC_HOST}" ]; then
echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}"
sleep 2
exit 1
fi
if [ -z "${IDRAC_PORT}" ]; then
echo "${RED}Please set a proper idrac port with IDRAC_PORT${NC}"
sleep 2
exit 1
fi
if [ -z "${IDRAC_USER}" ]; then
echo "${RED}Please set a proper idrac user with IDRAC_USER${NC}"
sleep 2
exit 1
fi
if [ -z "${IDRAC_PASSWORD}" ]; then
echo "${RED}Please set a proper idrac password with IDRAC_PASSWORD${NC}"
sleep 2
exit 1
fi
echo "Environment ok"
cd /app
if [ ! -d "lib" ]; then
echo "Creating library folder"
mkdir lib
fi
if [ ! -f avctKVM.jar ]; then
echo "Downloading avctKVM"
wget https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctKVM.jar --no-check-certificate
if [ ! $? -eq 0 ]; then
echo "${RED}Failed to download avctKVM.jar, please check your settings${NC}"
sleep 2
exit 2
fi
fi
if [ ! -f lib/avctKVMIOLinux64.jar ]; then
echo "Downloading avctKVMIOLinux64"
wget -O lib/avctKVMIOLinux64.jar https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctKVMIOLinux64.jar --no-check-certificate
if [ ! $? -eq 0 ]; then
echo "${RED}Failed to download avctKVMIOLinux64.jar, please check your settings${NC}"
sleep 2
exit 2
fi
fi
if [ ! -f lib/avctVMLinux64.jar ]; then
echo "Downloading avctVMLinux64"
wget -O lib/avctVMLinux64.jar https://${IDRAC_HOST}:${IDRAC_PORT}/software/avctVMLinux64.jar --no-check-certificate
if [ ! $? -eq 0 ]; then
echo "${RED}Failed to download avctVMLinux64.jar, please check your settings${NC}"
sleep 2
exit 2
fi
fi
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}"
if [ -n "$IDRAC_KEYCODE_HACK" ]; then
echo "Enabling keycode hack"
export LD_PRELOAD=/keycode-hack.so
fi
exec java -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" &
# If an iso exists at the specified location, mount it
[ -f "/vmedia/$VIRTUAL_ISO" ] && /mountiso.sh
wait