2013-06-13 16:14:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
# This routine when called, contacts xcatd. It will return to the caller when xcatd is
|
|
|
|
# ready to process the request
|
|
|
|
# It is called by xcatdsklspost before calling getpostscripts.awk
|
|
|
|
# it is called by remoteshell before calling getcredentials.awk
|
|
|
|
#
|
2013-09-16 08:48:57 +00:00
|
|
|
exec {REMOTEFD}<>/dev/udp/$1/$2
|
|
|
|
echo "resourcerequest: xcatd" >&$REMOTEFD
|
2013-06-13 16:14:08 +00:00
|
|
|
parpid=$$
|
|
|
|
touch /tmp/goahead.$parpid
|
|
|
|
touch /tmp/killme.$parpid
|
|
|
|
exec 2> /dev/null
|
|
|
|
while ! grep 'resourcerequest: ok' /tmp/goahead.$parpid > /dev/null; do
|
|
|
|
(
|
2013-09-16 08:48:57 +00:00
|
|
|
echo "resourcerequest: xcatd" >&$REMOTEFD
|
|
|
|
exec {LOCALFD}<>/proc/self/stat
|
|
|
|
read mystat<&$LOCALFD
|
2013-06-14 14:39:06 +00:00
|
|
|
mypid=$(echo $mystat|cut -d " " -f 4)
|
2013-06-13 16:14:08 +00:00
|
|
|
(sleep $(((RANDOM%60)+120)).$((RANDOM%50)); if [ -f /tmp/killme.$parpid ]; then kill -TERM $mypid; fi) &
|
2013-06-14 14:39:12 +00:00
|
|
|
echo $! > /tmp/sleeperpid.$parpid
|
2013-09-16 08:48:57 +00:00
|
|
|
exec awk '{print $0 > "/tmp/goahead.'$parpid'";exit}' <&$REMOTEFD
|
|
|
|
exec {LOCALFD}>&-
|
2013-06-13 16:14:08 +00:00
|
|
|
)
|
|
|
|
done
|
2013-06-14 14:39:12 +00:00
|
|
|
sleeper=$(cat /tmp/sleeperpid.$parpid)
|
|
|
|
sleeper=$(ps -ef|awk "\$3==$sleeper"|awk '{print $2}')
|
|
|
|
rm /tmp/goahead.$parpid
|
|
|
|
rm /tmp/sleeperpid.$parpid
|
2013-06-13 16:14:08 +00:00
|
|
|
rm /tmp/killme.$parpid
|
2013-09-16 08:48:57 +00:00
|
|
|
exec {REMOTEFD}>&-
|
2013-08-19 17:29:51 +00:00
|
|
|
kill -TERM $sleeper
|