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