-
Notifications
You must be signed in to change notification settings - Fork 233
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
infra/image/system-services: Enhance checks, also fix reverse zone #1282
infra/image/system-services: Enhance checks, also fix reverse zone #1282
Conversation
4d7839a
to
f3493ab
Compare
f3493ab
to
27b6131
Compare
@@ -1,26 +1,82 @@ | |||
#!/bin/bash -eu | |||
|
|||
function validFQDN() |
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.
really minor and cosmetic: shell naming conventions lowercase and separate words with underscore, what about
valid_fqdn()
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.
Fixed
return 0 | ||
} | ||
|
||
function validIPv4() |
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.
valid_ipv4()
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.
Fixed
local rematch="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" | ||
|
||
[[ "${ip}" =~ ${rematch} ]] || return 1 | ||
for i in ${ip//./ }; do |
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.
cosmetic:
s/i/octet/g
octet has a meaning
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.
This is a bash syntax to replace "." (dot) with " " (space). ${parameter//pattern/string} replaces in the whole string and ${parameter/pattern/string} only the first match.
infra/image/system-service/fixnet.sh
Outdated
echo " IP: '${IP}'" | ||
echo | ||
|
||
if grep -Pq "[[:space:]]${HOSTNAME}([[:space:]]|$)" /etc/hosts |
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.
grep -P is not available on all systems by default, what about
grep -qE "\s$HOSTNAME(\s|$)" /etc/hosts
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.
Fixed
infra/image/system-service/fixnet.sh
Outdated
echo | ||
|
||
if grep -Pq "[[:space:]]${HOSTNAME}([[:space:]]|$)" /etc/hosts | ||
then | ||
sed -ie "s/.*${HOSTNAME}/${IP}\t${HOSTNAME}/" /etc/hosts |
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.
sed sometimes is risky,
what about
sed -i.bak
it will create a backup before modifying.
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.
Fixed
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.
LGTM! feel free to merge.
@t-woerner I just have cosmetics changes for your consideration, really minor things.
27b6131
to
929ccb1
Compare
Checks for IPv4 addresses have been added and reverse zone handling for fixipaip.sh The services are logging StandardOutput and StandardError to journal now.
929ccb1
to
e05fbce
Compare
Checks for IPv4 addresses have been added and reverse zone handling for fixipaip.sh
The services are logging StandardOutput and StandardError to journal now.