X7ROOT File Manager
Current Path:
/usr/local/VMOptimizationTools_2.50.0
usr
/
local
/
VMOptimizationTools_2.50.0
/
๐
..
๐
LinuxUpdate.XML
(645 B)
๐
SangforVMSTool
(3.11 KB)
๐
SangforVMSTool.service
(194 B)
๐
action_common.sh
(13.34 KB)
๐
busybox_cmd_ln.sh
(2.24 KB)
๐
collect_test_data.sh
(1.16 KB)
๐
common_config.sh
(278 B)
๐
data_test_tool.sh
(12.59 KB)
๐
debian_vmconfig.sh
(10.74 KB)
๐
guest_system_config.sh
(1.82 KB)
๐
hostname_config
(1 B)
๐
log.sh
(1.36 KB)
๐
mod_test.sh
(3.69 KB)
๐
mod_test1.sh
(914 B)
๐
net_common.sh
(915 B)
๐
network_config
(1 B)
๐
pwd_info_config
(1 B)
๐
redhat_vmconfig.sh
(11.14 KB)
๐
sangfor_guest_datareport
(21.66 KB)
๐
sangfor_heartalive.sh
(2.37 KB)
๐
sangfor_module_update
(28.11 KB)
๐
sangfor_set_network.sh
(504 B)
๐
sangfor_sfping
(3.85 KB)
๐
sangfor_sshkey_gen
(1.29 KB)
๐
sangfor_update_ipc_callback
(5.29 KB)
๐
sangfor_vm_proxyd
(3.45 KB)
๐
sangfor_vm_proxyd_r
(4.4 KB)
๐
sangfor_vm_proxyd_w
(1.32 KB)
๐
sangfor_vmconfig
(2.4 KB)
๐
sangfor_vmconfig_common
(27.99 KB)
๐
sangfor_vmconfig_ipc_callback
(4.75 KB)
๐
sangfor_watchdog
(3.95 KB)
๐
sfping
(13.63 KB)
๐
sfping.pl
(6.15 KB)
๐
startall
(1.78 KB)
๐
stopall
(1.11 KB)
๐
suse_vmconfig.sh
(6.19 KB)
๐
tools_x64
๐
tools_x86
๐
uni_test.sh
(2.59 KB)
๐
update_common_func
(4.35 KB)
๐
update_common_header
(4.86 KB)
๐
update_config
(2.89 KB)
๐
update_install
(28.84 KB)
๐
update_network.flag
(1 B)
๐
virtio_nic_attr_set.sh
(2.42 KB)
๐
virtio_nic_compat.sh.old1578331486
(5.28 KB)
๐
vm_ip_recover.sh
(16.66 KB)
๐
vm_ipc.sh
(9.06 KB)
๐
vmconfig_common_func
(10.76 KB)
๐
vmconfig_common_header
(3.37 KB)
๐
vmconfig_config
(805 B)
๐
vmtools-install.sh
(31.16 KB)
๐
watch_test.sh
(313 B)
๐
watchdog.sh
(1.39 KB)
๐
x64
๐
x86
Editing: debian_vmconfig.sh
#!/bin/bash shell_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) . "${shell_dir}/vmconfig_common_func" # interfaces config operation # param $1: ifname, such as eth0 # param $2: operation del|backup # return 0(success),1(fail) interfaces_cfg_handle_one() { local line_num=1 local found_flag=0 local start_line=0 local end_line=0 local ifname=$1 local op=$2 local backup_file=$3 if [ x"${ifname}" == x"" ];then log_error "invalid ifname" return 1 fi while read line do if [ ! $found_flag -eq 1 ];then #get the interface config start position ret=`echo $line | grep "^\s*iface" | grep "inet "| awk -v ifname="$ifname" '{if ($2==ifname) print 1}'` if [ x"$ret" == x"1" ];then found_flag=1 start_line=$line_num log_debug "found start line $line,num=$line_num" fi else res=`echo $line | grep "^\s*auto"` if [ x"$res" != x"" ];then log_debug "found end line $line,num=$line_num" end_line=`expr $line_num - 1` break fi res=`echo $line | grep "^\s*iface"` if [ x"$res" != x"" ];then log_debug "found end line $line,num=$line_num" end_line=`expr $line_num - 1` break fi fi line_num=`expr $line_num + 1` done < $g_debian_network_cfg if [ $found_flag -eq 0 ];then log_debug "not found $ifname config" return 1 fi if [ $end_line -eq 0 ];then echo "$ifname is the last config" #reach end end_line=`expr $line_num - 1` fi log_debug "$op $ifname config line $start_line:$end_line" if [ x"${op}" == x"del" ];then log_info "delete $ifname config" sed -i "$start_line,${end_line}d" $g_debian_network_cfg #"auto ethxx" str may be in any position sed -i "/^\s*auto\s*$ifname\s*$/d" $g_debian_network_cfg else log_info "save $ifname config to $backup_file" sed -n "/^\s*auto\s*$ifname\s*$/p" $g_debian_network_cfg > $backup_file sed -n "$start_line,${end_line}p" $g_debian_network_cfg >> $backup_file fi return 0 } # ๅ ้คๅคip้ ็ฝฎ๏ผๅฆeth1:20็ญๆฅๅฃ # param $1: ifname,eg:eth0 # return: none del_interfaces_mul_ip_config() { local ifname=$1 # ๆฅ่ฏขๆฅๅฃๅๅนถๅ ้ค for i in `cat $g_debian_network_cfg| grep "inet " | grep "^\s*iface\s*${ifname}:" |awk '{print $2}'` do interfaces_cfg_handle_one "$i" "del" log_info "del multiip config,ifname=$i" done } interfaces_cfg_handle() { local ifname=$1 local op=$2 if [ x"${op}" == x"del" ];then while true do interfaces_cfg_handle_one $ifname $op ret=`cat $g_debian_network_cfg |grep "inet "| grep "^\s*iface\s*$ifname\s"` if test -z "$ret";then break fi log_debug "$ifname has more config" done # ็ฑไบๆฅๅฃๅๆช็ฅ๏ผๅคipๅ็ฌๅค็๏ผๆ ผๅผethx:xx del_interfaces_mul_ip_config $ifname else interfaces_cfg_handle_one $ifname $op fi return 0 } # debian series system generate network config # param $1: ifname,eg:eth0 # param $2: protocol,eg:dhcp|static # param $3: ip,eg:192.168.100.100 # param $4: net mask,eg:255.255.255.0 # param $5: gateway,eg:192.168.100.1 # param $6: primary dns,eg:192.168.100.1 # param $7: secondary dns,eg:8.8.8.8 # return 0(success),1(fail) debian_gen_network_cfg_file() { local ifname=$1 local protocol=$2 local ipaddr=$3 local netmask=$4 local gateway=$5 local dns1=$6 local dns2=$7 test -z "$ifname" && return 1 if [ x"$protocol" != x"$PROTO_STATIC" ] && [ x"$protocol" != x"$PROTO_DHCP" ];then log_error "error,invalid proto $protocol" return 1 fi log_info "config:{$ifname,$protocol,$ipaddr,$netmask,$gateway,$dns1,$dns2}" cfg_file="/tmp/ifcfg-$ifname" echo "auto $ifname" > $cfg_file echo "iface $ifname inet $protocol" >> $cfg_file is_valid_inet_address $ipaddr if [ $? -eq 0 ];then echo "address $ipaddr" >> $cfg_file fi is_valid_inet_address $netmask if [ $? -eq 0 ];then echo "netmask $netmask" >> $cfg_file fi is_valid_inet_address $gateway if [ $? -eq 0 ];then echo "gateway $gateway" >> $cfg_file fi metric=`cat /proc/net/dev |sed -n "/$ifname:/="` if ! test -z $metric;then echo "metric 10$metric" >> $cfg_file fi is_valid_inet_address $dns1 dns1_ret=$? is_valid_inet_address $dns2 dns2_ret=$? if [ $dns1_ret -eq 0 ] || [ $dns2_ret -eq 0 ];then echo "dns-nameservers $dns1 $dns2" >> $cfg_file fi interfaces_cfg_handle "$ifname" "del" cat "$cfg_file" >> "$g_debian_network_cfg" return 0 } # debian series system generate network config # param $1: ifname,eg:eth0 # param $2: ip,eg:192.168.100.100 # param $3: net mask,eg:255.255.255.0 # param $4: gateway,eg:192.168.100.1 # param $5: primary dns,eg:192.168.100.1 # param $6: secondary dns,eg:8.8.8.8 debian_network_cfg_handle() { local ifname=$1 local ipaddr=$2 local netmask=$3 local gateway=$4 local dns1=$5 local dns2=$6 local protocol=$PROTO_STATIC if test -z "$ifname";then log_error "ifname is needed" return 0 fi # ๅฆๆๆฒกๆ้ ็ฝฎip๏ผ่ทๅๆฅๅฃๅฝๅ็้ ็ฝฎ if test -z "$ipaddr";then log_info "$ifname not found ip config" method=`nmcli_get_config_ip_method $ifname` if ! test -z "$method";then #ไปnetworkmanager้ ็ฝฎไธญ่ทๅ if [ x"$method" == x"manual" ];then protocol=$PROTO_STATIC ipaddr=`nmcli_get_config_ip $ifname` netmask=`nmcli_get_config_mask $ifname` gateway=`nmcli_get_config_gateway $ifname` else protocol=$PROTO_DHCP fi log_info "[nmcli]origin proto:$protocol,ip:$ipaddr,netmask:$netmask,gateway:$gateway" else #ไป/etc/network/interfaces้ ็ฝฎไธญ่ทๅ log_info "get info from config $ifname" backup_file="/tmp/$ifname.cfg" interfaces_cfg_handle_one "$ifname" "backup" "$backup_file" protocol=`cat $backup_file | grep "inet "| grep "iface" |awk '{print $4}'` if [ x"$PROTO_STATIC" == x"$protocol" ];then ipaddr=`cat $backup_file | grep "^\s*address" | awk '{print $2}'` ipaddr=`remove_quotation_mark "$ipaddr"` netmask=`cat $backup_file | grep "^\s*netmask" | awk '{print $2}'` netmask=`remove_quotation_mark "$netmask"` gateway=`cat $backup_file | grep "^\s*gateway" | awk '{print $2}'` gateway=`remove_quotation_mark "$gateway"` else protocol=$PROTO_DHCP fi log_info "[config]origin proto:$protocol,ip:$ipaddr,netmask:$netmask,gateway:$gateway" fi fi # ้ ็ฝฎไธญๅฏ่ฝ่ทๅไธๅฐip๏ผ้่ฟๅฝไปค่ทๅ if [ x"$PROTO_STATIC" == x"$protocol" ];then if test -z "$ipaddr" || test -z "$netmask";then log_warn "$ifname get config from cmd" ipaddr=`get_if_ip $ifname` netmask=`get_if_mask $ifname` if test -z "$ipaddr" || test -z "$netmask";then log_warn "$ifname get ip info failed,use default proto (dhcp)" protocol=$PROTO_DHCP else protocol=$PROTO_STATIC fi gateway=`get_if_gateway $ifname` log_info "[cmd]origin proto:$protocol,ip:$ipaddr,netmask:$netmask,gateway:$gateway" fi fi debian_gen_network_cfg_file "$ifname" "$protocol" "$ipaddr" "$netmask" "$gateway" "$dns1" "$dns2" ip a flush dev "$ifname" >/dev/null 2>&1 return 0 } # debian series system write dns config to temp config file # param $1: ifname,eg:eth0 # param $2: primary dns,eg:192.168.100.1 # param $3: secondary dns,eg:8.8.8.8 # return 0(success),1(fail) debian_gen_dns_cfg_file() { #่พๅ ฅๅๆฐ local ifaces=$1 local dns1=$2 local dns2=$3 if test -z "$ifaces";then log_error "ifaces($ifaces) is needed" return 1 fi #ๅคๆญๆฏๅฆๅๆณdns is_valid_inet_address $dns1 dns1_ret=$? if [ -n "$dns2" ];then is_valid_inet_address $dns2 dns2_ret=$? else dns2_ret=0 fi if [ $dns1_ret -eq 0 ] && [ $dns2_ret -eq 0 ];then #ไฟฎๆน้ ็ฝฎๆไปถไธญ็dns for ifname in $ifaces; do log_info "debian dns config,iface: $ifname" cfg_file="/tmp/ifcfg-$ifname" new_config="" # ๅคไปฝๆง็ฝๅฃ้ ็ฝฎ backup_file="/etc/network/$ifname.cfg" interfaces_cfg_handle_one "$ifname" "backup" "$backup_file" cat "$backup_file">"$cfg_file" if [ -n "$dns2" ];then new_config="dns-nameservers $dns1 $dns2" else new_config="dns-nameservers $dns1" fi # ไธดๆถๆไปถไธญๅ ้คๆงDNS้ ็ฝฎ๏ผๅๅ ฅๆฐDNS้ ็ฝฎ sed -i "/^\s*dns-nameservers.*/d" $cfg_file echo "$new_config" >> $cfg_file # ๅ ้ค็ฝๅฃๆง้ ็ฝฎ๏ผๅจๆไปถๆซๅฐพๅๅ ฅๆฐ้ ็ฝฎ interfaces_cfg_handle "$ifname" "del" cat "$cfg_file" >> "$g_debian_network_cfg" done return 0 else log_error "dns is invalid! dns1:$dns1, dns2:$dns2" return 1 fi } # debian series system generate dns config without restart # param $1: ifname,eg:eth0 # param $2: primary dns,eg:192.168.100.1 # param $3: secondary dns,eg:8.8.8.8 # return 0(success),1(fail) debian_dns_cfg_handle() { local ifaces=$1 local dns1=$2 local dns2=$3 log_info "debian_dns_cfg_handle params: interfaces:$ifaces, major dns:$dns1, minor dns:$dns2" if test -z "$ifaces";then log_error "ifaces is needed" return 1 fi debian_gen_dns_cfg_file "$ifaces" "$dns1" "$dns2" tmp_file="${g_dns_config_file}_sangfor_tmp" rm -f $tmp_file if [ "$dns1" != "" ]; then # PS๏ผๆ่ฟ็ฎ้ตๅพชๆ็ญ่ฟ็ฎ่งๅ๏ผๅฝ็ฌฌไธไธชๆกไปถไธบ็ๅฐฑ็ดๆฅ่ฟๅ๏ผๅ้ข็ๅฐฑไธๆง่กไบ๏ผๆ ๅ้ข็ๆไปค่ฟ่กๅคฑ่ดฅไบๆไผๆง่กๅ็ปญๆไปค echo "nameserver $dns1" >> $tmp_file || echo "nameserver $dns1" >> $tmp_file || log_error "append $dns1 failed" fi if [ "$dns2" != "" ]; then echo "nameserver $dns2" >> $tmp_file || echo "nameserver $dns2" >> $tmp_file || log_error "append $dns2 failed" fi log_info "rename file $tmp_file to $g_dns_config_file" mv -f $tmp_file $g_dns_config_file || mv -f $tmp_file $g_dns_config_file || log_error "rename failed!!" return 0 }
Upload File
Create Folder