Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions templates/common/baremetal/files/NetworkManager-mdns-hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
filesystem: "root"
mode: 0755
path: "/etc/NetworkManager/dispatcher.d/40-mdns-hostname"
contents:
inline: |
#!/bin/bash
STATUS=$2
case "$STATUS" in
up|down|dhcp4-change|dhcp6-change|hostname)
logger -s "NM mdns-hostname triggered by ${2}."
set +e
t_hostname=$(hostname)
if [ -z "${t_hostname}" ]; then
t_hostname="localhost"
fi
mkdir -p /etc/mdns
echo "${t_hostname}">/etc/mdns/hostname
logger -s "Hostname changed: ${t_hostname}"
;;
*)
;;
esac
21 changes: 19 additions & 2 deletions templates/common/baremetal/files/baremetal-mdns-publisher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,35 @@ contents:
env:
- name: DEFAULT_LOCAL_HOSTNAME
value: "localhost"
- name: RUNTIMECFG_HOSTNAME_PATH
value: "/etc/mdns/hostname"
command:
- "/bin/bash"
- "-c"
- |
#/bin/bash
while [ "$(hostname)" == "$DEFAULT_LOCAL_HOSTNAME" ]
function get_hostname()
{
if [[ -s $RUNTIMECFG_HOSTNAME_PATH ]]; then
cat $RUNTIMECFG_HOSTNAME_PATH
else
# if hostname wasn't updated by NM script, read hostname
hostname
fi
}
while [ "$(get_hostname)" == "$DEFAULT_LOCAL_HOSTNAME" ]
do
echo "hostname is still ${DEFAULT_LOCAL_HOSTNAME}"
sleep 10
sleep 1
done
volumeMounts:
- name: conf-dir
mountPath: "/etc/mdns"
- name: render-config
image: {{ .Images.baremetalRuntimeCfgImage }}
env:
- name: RUNTIMECFG_HOSTNAME_PATH
value: "/etc/mdns/hostname"
command:
- runtimecfg
- render
Expand Down