[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.145.36.252: ~ $
#!/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

Filemanager

Name Type Size Permission Actions
debian-get_dhcp.sh File 1.32 KB 0755
debian-netplan_restart.sh File 439 B 0755
debian-restart.sh File 1.34 KB 0755
debian-set_dhcp.sh File 1.62 KB 0755
debian-set_gateway.sh File 1.85 KB 0755
debian-set_ip.sh File 4.35 KB 0755
debian-set_route.sh File 2.06 KB 0755
functions File 20.34 KB 0755
netplan-cfg.py File 8.63 KB 0755
netplan-cfg.pyc File 10.45 KB 0644
netplan-cfg.pyo File 10.45 KB 0644
nm-get_dhcp.sh File 834 B 0755
nm-restart.sh File 488 B 0755
nm-set_dhcp.sh File 1.23 KB 0755
nm-set_dns.sh File 1.71 KB 0755
nm-set_gateway.sh File 1.11 KB 0755
nm-set_ip.sh File 3.02 KB 0755
nm-set_route.sh File 1.12 KB 0755
redhat-get_dhcp.sh File 1.58 KB 0755
redhat-restart.sh File 429 B 0755
redhat-set_dhcp.sh File 2 KB 0755
redhat-set_gateway.sh File 1.54 KB 0755
redhat-set_ip.sh File 5.36 KB 0755
redhat-set_route.sh File 1.33 KB 0755
set_dns.sh File 4.03 KB 0755
suse-get_dhcp.sh File 1 KB 0755
suse-restart.sh File 255 B 0755
suse-set_dhcp.sh File 1.7 KB 0755
suse-set_gateway.sh File 970 B 0755
suse-set_ip.sh File 3.01 KB 0755
suse-set_route.sh File 1.12 KB 0755