#! /bin/bash
+# Copyright (C) 2011 GRNET S.A.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
### BEGIN TASK INFO
# Provides: AssignHostname
# RunBefore: UmountImage
set -e
. "@commondir@/common.sh"
+# Check if the task should be prevented from running.
+check_if_excluded
+
windows_hostname() {
local target="$1"
local password="$2"
redhat)
sed -ie "s/HOSTNAME=.*$/HOSTNAME=$hostname/g" "$target/etc/sysconfig/network";;
slackware|suse)
- #local domain=$(sed -e 's/^[^\.]*//g' < /etc/HOSTNAME)
-
- # In slackware hostname and domain name are joined together. For now I
- # will not retain the domain name.
-
- echo "$hostname" > "${target}/etc/HOSTNAME";;
- gentoo)
- sed -ie "s/\(\(HOSTNAME\)\|\(hostname\)\)=.*$/\1=\"$hostname\"/" "$target/etc/conf.d/hostname";;
+ #local domain=$(sed -e 's/^[^\.]*//g' < /etc/HOSTNAME)
+
+ # In slackware hostname and domain name are joined together. For now
+ # I will not retain the domain name.
+ echo "$hostname" > "${target}/etc/HOSTNAME";;
+ gentoo)
+ sed -ie "s/\(\(HOSTNAME\)\|\(hostname\)\)=.*$/\1=\"$hostname\"/" "$target/etc/conf.d/hostname";;
esac
# Some Linux distributions assign the hostname to 127.0.1.1 in order to be
log_error "Hostname is missing"
fi
-if [ "$SNF_IMAGE_OS" = "windows" ]; then
+if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then
windows_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
-elif [ "$SNF_IMAGE_OS" = "linux" ]; then
+elif [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "linux" ]; then
linux_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
fi
-cleanup
-trap - EXIT
-
exit 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :