Skip to content

Commit c60badf

Browse files
authored
Merge pull request cirros-dev#40 from smoser/fix/shutdown-from-rc-local
test-boot: shutdown from rc.local rather than directly from user-data.
2 parents 7a2b0c3 + 940a71a commit c60badf

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

bin/test-boot

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ POWEROFF=${POWEROFF:-false}
2323

2424
echo '{"instance-id": "9068aef2-213e-4e43-830f-accdbadde897"}' > meta-data
2525

26-
if [ "true" == $POWEROFF ]; then
27-
{ echo '#!/bin/sh'; echo 'echo Hello from inside'; echo 'poweroff -f'; } > user-data
28-
else
26+
if [ "$POWEROFF" != "true" ]; then
2927
echo "" > user-data
28+
else
29+
cat >user-data <<"EOF"
30+
#!/bin/sh
31+
rclocal="/etc/rc.local"
32+
cat >>$rclocal <<"END_RC_LOCAL"
33+
#!/bin/sh
34+
read up idle </proc/uptime
35+
echo "[$up] Hello and goodbye from inside $0"
36+
poweroff
37+
END_RC_LOCAL
38+
chmod 755 $rclocal
39+
EOF
3040
fi
3141

3242
cloud-localds -d qcow2 seed.img user-data meta-data

0 commit comments

Comments
 (0)