slitaz-vz annotate vz-scripts/openvz/slitaz-set_hostname.sh @ rev 0

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