-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabstart.sh
executable file
·93 lines (73 loc) · 2.82 KB
/
labstart.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
#!/bin/sh
# version 1.10 11-April 2024
# in theory it should work like this using Linux jason query "jq"
#lab_sku=`echo '{"username":"[email protected]","tenant":"hol-test","lab":"HOL-8803-01"}' | jq '. | .lab' | sed s/\"//g`
# but what we get is this without the quotes so jq will not process
#vlp="{username:[email protected],tenant:hol-test,lab:HOL-8803-01}"
#furthermore the shell is not happy with the brackets and colons so unless the argument is quoted it doesn't work.
#therefore we have VLP Vm Script write the information in /tmp/vlpagent.txt at lab start (console open)
#Note: the lab console will not open if this script does not run to completion
# get the lab information from VLP
labstarttxt=/tmp/labstart.txt
cp $labstarttxt .
rawvlp=`cat $labstarttxt`
# DEBUG
#labstarttxt=labstart.txt
tenant=`cat $labstarttxt | cut -f2 -d ':' | cut -f1 -d',' | sed s/}//g`
[ -z "${tenant}" ] && tenant=""
student=`cat $labstarttxt | cut -f3 -d ':' | cut -f1 -d',' | sed s/}//g`
[ -z "${student}" ] || [ "${student}" = "unknown" ] && student=""
lab_sku=`cat $labstarttxt | cut -f4 -d ':' | cut -f1 -d',' | sed s/}//g`
[ -z "${lab_sku}" ] && lab_sku=""
#class=`cat $labstarttxt | cut -f5 -d ':' | cut -f1 -d',' | sed s/}//g`
#[ -z "${class}" ] && class=""
dp=`cat $labstarttxt | cut -f5 -d ':' | sed s/}//g`
[ -z "${dp}" ] && dp=""
vlp="${tenant}:${student}:${lab_sku}:${dp}"
#echo $vlp
#exit 0
# this file is created everytime the console opens
rm $labstarttxt
# /home/holuser/labstartup.sh creates the vPod_SKU.txt from the config.ini on the Main Console
vPod_SKU=`cat /tmp/vPod_SKU.txt`
holroot=/home/holuser/hol
lmcholroot=/lmchol/hol
wmcholroot=/wmchol/hol
LMC=false
WMC=false
# write the logs to the Main Console (LMC or WMC)
while true;do
if [ -d ${lmcholroot} ];then
logfile=${lmcholroot}/vmscript.log
echo "LMC detected." >> ${logfile}
mcholroot=${lmcholroot}
desktopcfg='/lmchol/home/holuser/desktop-hol/VMware.config'
LMC=true
break
elif [ -d ${wmcholroot} ];then
logfile=${wmcholroot}/vmscript.log
echo "WMC detected." >> ${logfile}
mcholroot=${wmcholroot}
desktopcfg='/wmchol/DesktopInfo/desktopinfo.ini'
WMC=true
break
fi
sleep 5
done
echo "Running captain script for $vPod_SKU because lab $lab_sku is active." >> $logfile
echo "Here is the VLP lab start message: $rawvlp" >> $logfile
# update the desktop display if needed
if [ ! -z "${lab_sku}" ];then
needed=`grep $lab_sku $desktopcfg`
else
needed=`grep $vlp $desktopcfg`
fi
if [ -z "$needed" ];then
#cat ${desktopcfg} | sed s/$vPod_SKU/$vlp/g > /tmp/desktop.config
cat ${desktopcfg} | sed s/$vPod_SKU/$lab_sku/g > /tmp/desktop.config
cp /tmp/desktop.config $desktopcfg
fi
# check and kill active labcheck processes
# remove labcheck at jobs
atrm $(atq | cut -f1)
# add lab sku specific commands here: