Skip to content

Commit 698171d

Browse files
CLOUDSTACK-8933 - Replace infinite loop by a for loop
- The loop will also sleep in between iterations, waiting for a couple of seconds and being multiplied by factor 2 per iteration
1 parent ac68f2a commit 698171d

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

‎systemvm/patches/debian/config/etc/init.d/cloud-early-config‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,31 @@ get_boot_params() {
117117
if [ ! -e /dev/vport0p1 ]; then
118118
log_it "/dev/vport0p1 not loaded, perhaps guest kernel is too old." && exit 2
119119
fi
120-
while [ -z "$cmd" ]; do
121-
while read line; do
122-
if [[ $line == cmdline:* ]]; then
123-
cmd=${line//cmdline:/}
120+
121+
local factor=2
122+
local progress=1
123+
for i in {1..5}
124+
do
125+
while read line; do
126+
if [[ $line == cmdline:* ]]; then
127+
cmd=${line//cmdline:/}
124128
echo $cmd > /var/cache/cloud/cmdline
125-
elif [[ $line == pubkey:* ]]; then
126-
pubkey=${line//pubkey:/}
127-
echo $pubkey > /var/cache/cloud/authorized_keys
128-
echo $pubkey > /root/.ssh/authorized_keys
129+
elif [[ $line == pubkey:* ]]; then
130+
pubkey=${line//pubkey:/}
131+
echo $pubkey > /var/cache/cloud/authorized_keys
132+
echo $pubkey > /root/.ssh/authorized_keys
129133
fi
130-
done < /dev/vport0p1
131-
# In case of reboot we do not send the boot args again.
132-
# so need not wait for them, as the boot args are already set at startup
133-
if [ -s /var/cache/cloud/cmdline ]
134-
then
135-
log_it "found a non empty cmdline file continuing"
136-
break;
134+
done < /dev/vport0p1
135+
# In case of reboot we do not send the boot args again.
136+
# So, no need to wait for them, as the boot args are already set at startup
137+
if [ -s /var/cache/cloud/cmdline ]
138+
then
139+
log_it "Found a non empty cmdline file. Will now exit the loop and proceed with configuration."
140+
break;
137141
fi
138-
done
142+
sleep ${progress}s
143+
progress=$[ progress * factor ]
144+
done
139145
chmod go-rwx /root/.ssh/authorized_keys
140146
;;
141147
vmware)

0 commit comments

Comments
 (0)