Commit 93c76023 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Detect CoreOS in get_base_distro()

parent 481cc9e5
......@@ -181,7 +181,9 @@ system_poweroff() {
get_base_distro() {
local root_dir=$1
if [ -e "$root_dir/etc/debian_version" ]; then
if [ -d "$root_dir/etc/coreos" ]; then
echo "coreos"
elif [ -e "$root_dir/etc/debian_version" ]; then
echo "debian"
elif [ -e "$root_dir/etc/redhat-release" ]; then
echo "redhat"
......
......@@ -66,6 +66,8 @@ linux_hostname() {
else
distro=$(get_base_distro "$target")
case "$distro" in
coreos)
echo "$hostname" > "$target/etc/hostname";;
redhat)
sed -i -e "s/HOSTNAME=.*$/HOSTNAME=$hostname/g" "$target/etc/sysconfig/network";;
slackware|suse)
......@@ -95,7 +97,9 @@ linux_hostname() {
# Some Linux distributions assign the hostname to 127.0.1.1 in order to be
# resolvable to an IP address. Lets replace this if found in /etc/hosts
sed -i -e "s/^[[:blank:]]*127\.0\.1\.1[[:blank:]].\+$/127.0.1.1\t$hostname/" "$target/etc/hosts"
if [ -f "$target/etc/hosts" ]; then
sed -i -e "s/^[[:blank:]]*127\.0\.1\.1[[:blank:]].\+$/127.0.1.1\t$hostname/" "$target/etc/hosts"
fi
}
freebsd_hostname() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment