-
Notifications
You must be signed in to change notification settings - Fork 0
improve startup reliability #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,12 @@ sysctl -q -w net.ipv6.conf.eth0.disable_ipv6=1 | |
| ip addr add 169.254.0.0/16 dev eth0 | ||
| ip link set eth0 up | ||
|
|
||
| tries=100 | ||
| until eval '(( $(< /sys/class/net/eth0/carrier) ))'; do | ||
| (( tries-- > 0 )) || exit 1 | ||
| sleep 0.1 | ||
| done | ||
|
|
||
|
Comment on lines
+22
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loop only verifies that an Ethernet cable is connected...not that the network interface is actually functional. Here are two suggestions from ChatGPT to check that a network interface is functional in a BASH script, both of which I tried in my terminal. The first starts a service dependent on systemd-run --wait --quiet --service-type=oneshot --property="After=network-online.target" /bin/trueThis second example is simpler, it reads a file like the one that you have. We would want this command to return From ChatGPT:
|
||
| echo $(get_metadata name) > /proc/sys/kernel/hostname | ||
|
|
||
| IP=$(get_metadata network-interfaces/0/ip) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
jq -eflag is a new trick for me, nice.Should we quote these variable assignments to protect against BASH code injection?
RUNNER_RELEASE_URL=$(...)...would become:
RUNNER_RELEASE_URL="$(...)"As a point of interest, I believe the
jqqueryif-thensnippet......could be simplified to this.
I haven't tried it, not certain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably prudent to do so just for best practices purposes.
Not sure if I exactly understand your suggestion. It's easy enough to try -- no token needed or anything. If you find a more concise way I'd certainly be interested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind on the
jqthing, I see theif...elseblock behaves slightly different than I had thought when I wrote that comment. My mistake.