slitaz-vz view vz-scripts/proxmox/slitaz-set_dns.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
line source
1 #!/bin/sh
2 # Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #
18 #
19 # Sets up resolver (/etc/resolv.conf) in a container.
21 set_dns()
22 {
23 local cfgfile="$1"
24 local server="$2"
25 local search="$3"
26 local srv
28 [ -f $cfgfile ] || touch $cfgfile
30 if [ -n "${search}" ]; then
31 put_param2 "${cfgfile}" search "${search}"
32 fi
33 if [ -n "${server}" ]; then
34 [ -f ${cfgfile} ] || touch ${cfgfile}
35 grep -v '^\s*nameserver\s' ${cfgfile} > ${cfgfile}.$$ &&
36 mv -f ${cfgfile}.$$ ${cfgfile} ||
37 error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE}
38 for srv in ${server}; do
39 echo "nameserver ${srv}" >> ${cfgfile}
40 done
41 fi
42 chmod 644 ${cfgfile}
43 }
46 set_dns /etc/resolv.conf "${NAMESERVER}" "${SEARCHDOMAIN}"
48 exit 0