wok-next diff vzctl/stuff/slitaz-set_hostname.sh @ rev 19287
get-vivaldi: update deps (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Jul 06 08:57:45 2016 +0200 (2016-07-06) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/vzctl/stuff/slitaz-set_hostname.sh Wed Jul 06 08:57:45 2016 +0200 1.3 @@ -0,0 +1,39 @@ 1.4 +#!/bin/bash 1.5 +# Copyright (C) 2000-2009, Parallels, Inc. All rights reserved. 1.6 +# Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org> 1.7 +# 1.8 +# This program is free software; you can redistribute it and/or modify 1.9 +# it under the terms of the GNU General Public License as published by 1.10 +# the Free Software Foundation; either version 2 of the License, or 1.11 +# (at your option) any later version. 1.12 +# 1.13 +# This program is distributed in the hope that it will be useful, 1.14 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 1.15 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.16 +# GNU General Public License for more details. 1.17 +# 1.18 +# You should have received a copy of the GNU General Public License 1.19 +# along with this program; if not, write to the Free Software 1.20 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1.21 +# 1.22 +# 1.23 +# Sets up hostname in a container running slitaz-like distro. 1.24 + 1.25 +function set_hostname() 1.26 +{ 1.27 + local cfgfile="$1" 1.28 + local hostname=$2 1.29 + 1.30 + [ -z "${hostname}" ] && return 0 1.31 + 1.32 + hostname=${hostname%%.*} 1.33 + 1.34 + echo "${hostname}" > ${cfgfile} 1.35 + 1.36 + hostname ${hostname} 1.37 +} 1.38 + 1.39 +change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}" 1.40 +set_hostname /etc/hostname "${HOSTNM}" 1.41 + 1.42 +exit 0