wok-next annotate vzctl/stuff/slitaz-set_hostname.sh @ rev 10621

enlightenment and libs: huge clean to bdeps and make it build
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 26 21:09:04 2011 +0200 (2011-05-26)
parents
children
rev   line source
erjo@8056 1 #!/bin/bash
erjo@8056 2 # Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
erjo@8056 3 # Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
erjo@8056 4 #
erjo@8056 5 # This program is free software; you can redistribute it and/or modify
erjo@8056 6 # it under the terms of the GNU General Public License as published by
erjo@8056 7 # the Free Software Foundation; either version 2 of the License, or
erjo@8056 8 # (at your option) any later version.
erjo@8056 9 #
erjo@8056 10 # This program is distributed in the hope that it will be useful,
erjo@8056 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
erjo@8056 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
erjo@8056 13 # GNU General Public License for more details.
erjo@8056 14 #
erjo@8056 15 # You should have received a copy of the GNU General Public License
erjo@8056 16 # along with this program; if not, write to the Free Software
erjo@8056 17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
erjo@8056 18 #
erjo@8056 19 #
erjo@8056 20 # Sets up hostname in a container running slitaz-like distro.
erjo@8056 21
erjo@8056 22 function set_hostname()
erjo@8056 23 {
erjo@8056 24 local cfgfile="$1"
erjo@8056 25 local hostname=$2
erjo@8056 26
erjo@8056 27 [ -z "${hostname}" ] && return 0
erjo@8056 28
erjo@8056 29 hostname=${hostname%%.*}
erjo@8056 30
erjo@8056 31 echo "${hostname}" > ${cfgfile}
erjo@8056 32
erjo@8056 33 hostname ${hostname}
erjo@8056 34 }
erjo@8056 35
erjo@8056 36 change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"
erjo@8056 37 set_hostname /etc/hostname "${HOSTNM}"
erjo@8056 38
erjo@8056 39 exit 0