/
usr
/
lib
/
vz-tools
/
tools
/
scripts
/
/usr/lib/vz-tools/tools/scripts
mkdir
upload
Name
Size
Mode
Actions
debian-get_dhcp.sh
1356
0755
edit
dl
rm
debian-netplan_restart.sh
439
0755
edit
dl
rm
debian-restart.sh
1376
0755
edit
dl
rm
debian-set_dhcp.sh
1659
0755
edit
dl
rm
debian-set_gateway.sh
1895
0755
edit
dl
rm
debian-set_ip.sh
4452
0755
edit
dl
rm
debian-set_route.sh
2109
0755
edit
dl
rm
functions
20831
0755
edit
dl
rm
netplan-cfg.py
8835
0755
edit
dl
rm
netplan-cfg.pyc
10697
0644
edit
dl
rm
netplan-cfg.pyo
10697
0644
edit
dl
rm
nm-get_dhcp.sh
834
0755
edit
dl
rm
nm-restart.sh
488
0755
edit
dl
rm
nm-set_dhcp.sh
1255
0755
edit
dl
rm
nm-set_dns.sh
1746
0755
edit
dl
rm
nm-set_gateway.sh
1132
0755
edit
dl
rm
nm-set_ip.sh
3095
0755
edit
dl
rm
nm-set_route.sh
1145
0755
edit
dl
rm
redhat-get_dhcp.sh
1618
0755
edit
dl
rm
redhat-restart.sh
429
0755
edit
dl
rm
redhat-set_dhcp.sh
2043
0755
edit
dl
rm
redhat-set_gateway.sh
1581
0755
edit
dl
rm
redhat-set_ip.sh
5487
0755
edit
dl
rm
redhat-set_route.sh
1367
0755
edit
dl
rm
set_dns.sh
4122
0755
edit
dl
rm
suse-get_dhcp.sh
1026
0755
edit
dl
rm
suse-restart.sh
255
0755
edit
dl
rm
suse-set_dhcp.sh
1743
0755
edit
dl
rm
suse-set_gateway.sh
970
0755
edit
dl
rm
suse-set_ip.sh
3079
0755
edit
dl
rm
suse-set_route.sh
1147
0755
edit
dl
rm
Edit:
/usr/lib/vz-tools/tools/scripts/set_dns.sh
(4122B)
#!/bin/bash # Copyright (c) 2015-2017, Parallels International GmbH # Copyright (c) 2017-2019 Virtuozzo International GmbH. All rights reserved. # # This script sets up resolver inside VM # # arguments: <NAMESERVER> <SEARCHDOMAIN> # <SEARCHDOMAIN> # Sets search domain(s). Modifies /etc/resolv.conf # <NAMESERVER> # Sets name server(s). Modifies /etc/resolv.conf prog="$0" path="${prog%/*}" funcs="$path/functions" if [ -f "$funcs" ] ; then . $funcs else echo "Program $0" echo "'$funcs' was not found" exit 1 fi ETH_DEV=$1 ETH_MAC=$2 NAMESERVER="$3" SEARCHDOMAIN="$4" HOSTNAME="$5" DISTR="$6" RESOLVDIR=/etc/resolvconf RESOLVCONF_LNK="${RESOLVDIR}/run/resolv.conf" RESOLVCONF="${RESOLVDIR}/resolv.conf.d/base" OSRELEASE=/etc/os-release function get_dhclient_conf() { local distr="$1" # Distro-specific defaults local cfgfile="/etc/dhclient.conf" # Ubuntu if [ "${distr}" = "debian" -a -e "${OSRELEASE}" -a \ "$(. ${OSRELEASE} 2>/dev/null && echo $ID)" = "ubuntu" ]; then cfgfile="/etc/dhcp3/dhclient.conf" # Normal debian uses /etc/dhcp/ elif [ "${distr}" = "debian" ]; then cfgfile="/etc/dhcp/dhclient.conf" # Redhat will prefer /etc/dhcp/ elif [ "${distr}" = "redhat" ]; then cfgfile="/etc/dhcp/dhclient.conf" # SUSE uses /etc/dhclient.conf by default elif [ "${distr}" = "suse" ]; then cfgfile="/etc/dhclient.conf" # Assume other distros prefer /etc/dhcp if exists elif [ -d "/etc/dhcp" ]; then cfgfile="/etc/dhcp/dhclient.conf" fi echo "${cfgfile}" } function set_dns() { local cfgfile="$1" local server="$2" local search="$3" local dhclientconf="$(get_dhclient_conf $4)" local srv fname search_value server_value if [ -L ${cfgfile} ]; then # resolvconf configuration fname="$(readlink "${cfgfile}")" if [ "${fname}" = "${RESOLVCONF_LNK}" ]; then cfgfile=${RESOLVCONF} fi fi [ -d "$(dirname ${dhclientconf})" ] || mkdir -p "$(dirname ${dhclientconf})" [ -f "${dhclientconf}" ] || touch "${dhclientconf}" if [ -n "${search}" ]; then # value for empty search list [ "${search}" = "remove" ] && search="" # Multiple spaces in name are unsupported by put_param2 sed -i "/prepend\s\+domain-search.*/d" ${dhclientconf} || \ error "Can't change file ${dhclientconf}" ${VZ_FS_NO_DISK_SPACE} if [ "${search}" = '#' -o -z "${search}" ]; then sed -i "/search.*/d" ${cfgfile} || \ error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} else put_param2 "${cfgfile}" search "${search}" for srch in ${search}; do [ -n "${search_value}" ] && search_value="${search_value}, " search_value="${search_value}\"${srch}\"" done put_param2 "${dhclientconf}" "prepend domain-search" "${search_value};" fi fi if [ -n "${server}" ]; then [ -f ${cfgfile} ] || touch ${cfgfile} sed -i "/nameserver.*/d" ${cfgfile} || \ error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} # Multiple spaces in name are unsupported by put_param2 sed -i "/prepend\s\+domain-name-servers.*/d" ${dhclientconf} || \ error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} [ "${server}" = '#' ] && return for srv in ${server}; do echo "nameserver ${srv}" >> ${cfgfile} || \ error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} [ -n "${server_value}" ] && server_value="${server_value}, " server_value="${server_value}${srv}" done put_param2 "${dhclientconf}" "prepend domain-name-servers" "${server_value};" fi chmod 644 ${cfgfile} chmod 644 ${dhclientconf} } function set_hostname() { local hostname="$1" local distr="$2" # nothing to do if [ -z "${hostname}" ]; then exit 0 fi hostname "${hostname}"; if [ "${distr}" = "redhat" ]; then put_param "/etc/sysconfig/network" "HOSTNAME" "${hostname}" elif [ "${distr}" = "suse" ]; then echo "${hostname}" > /etc/HOSTNAME elif [ "${distr}" = "debian" ]; then echo "${hostname}" > /etc/hostname fi } is_nm_active if [ $? -eq 0 ]; then call_nm_script $0 "$@" exit $? fi set_dns /etc/resolv.conf "${NAMESERVER}" "${SEARCHDOMAIN}" "${DISTR}" set_hostname "${HOSTNAME}" "${DISTR}" exit 0
Save
cmd:
run