mirror of
https://github.com/lesderid/image-archlinux
synced 2025-04-11 14:45:39 +02:00
Added dispatcher.d hostname hook (#1)
This commit is contained in:
parent
4c2e0d963c
commit
22588c52d9
16
patches/etc/NetworkManager/dispatcher.d/12-ochostname
Executable file
16
patches/etc/NetworkManager/dispatcher.d/12-ochostname
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
interface=$1
|
||||
action=$2
|
||||
|
||||
if [ "$interface" = "eth0" -a "$action" = "up" ]
|
||||
then
|
||||
metadata_host_name=$(/usr/local/bin/oc-metadata --cached HOSTNAME)
|
||||
if [ "x$metadata_host_name" != "x" ]
|
||||
then
|
||||
echo $metadata_host_name > /etc/hostname
|
||||
sed "/^127.0.1.1[ \t].*$/ s/.*$/127.0.1.1\t$metadata_host_name/" -i /etc/hosts
|
||||
sed "/^127.0.0.1[ \t]localhost/ s/localhost.*$/localhost $metadata_host_name/" -i /etc/hosts
|
||||
hostnamectl set-hostname $metadata_host_name
|
||||
fi
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user