Skip to content

Commit 62da9c3

Browse files
committed
fix: bail out if curl is not installed
1 parent 76a69d3 commit 62da9c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mkosi.profiles/gcp/mkosi.extra/usr/bin/set-hostname.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
if ! which curl; then
4+
echo "curl is not present on system, exiting..."
5+
exit 0
6+
fi
7+
38
while true; do
49
if hostname=$(
510
curl --header "Metadata-Flavor: Google" --silent --show-error \
@@ -10,6 +15,8 @@ while true; do
1015
echo 127.0.0.1 "${hostname}" >> /etc/hosts
1116
systemctl restart rsyslog
1217
exit 0
18+
else
19+
echo "Failed to query metadata service, will retry in 1s"
1320
fi
1421

1522
sleep 1

0 commit comments

Comments
 (0)