X-Git-Url: https://code.grnet.gr/git/snf-image/blobdiff_plain/bad5ca1ff3682e08a66375ff2b55eaed9acc830a..b97ada713646ab299012616aab94f317d03ce755:/snf-image-helper/tasks/50AssignHostname.in diff --git a/snf-image-helper/tasks/50AssignHostname.in b/snf-image-helper/tasks/50AssignHostname.in index 3c11246..a944c49 100644 --- a/snf-image-helper/tasks/50AssignHostname.in +++ b/snf-image-helper/tasks/50AssignHostname.in @@ -1,15 +1,35 @@ #! /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 # RunAfter: InstallUnattend -# Short-Description: Assign the Hostname of Computer Name in the instance -### END TAST INFO +# Short-Description: Assign Hostname/Computer Name to the instance +### END TASK INFO 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" @@ -39,14 +59,13 @@ linux_hostname() { 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 @@ -62,15 +81,12 @@ if [ -z "$SNF_IMAGE_HOSTNAME" ]; then log_error "Hostname is missing" fi -if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then +if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then windows_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME" -elif [ "$SNF_IMAGE_TYPE" = "extdump" ]; 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 :