X7ROOT File Manager
Current Path:
/usr/local/VMOptimizationTools_2.69.0
usr
/
local
/
VMOptimizationTools_2.69.0
/
๐
..
๐
LinuxUpdate.XML
(647 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
(16.62 KB)
๐
debian_vmconfig.sh
(13.48 KB)
๐
driver
๐
guest_system_config.sh
(1.82 KB)
๐
hostname_config
(1 B)
๐
ipv6_network_config
(94 B)
๐
log.sh
(1.36 KB)
๐
mod_test.sh
(3.69 KB)
๐
mod_test1.sh
(914 B)
๐
net_common.sh
(915 B)
๐
network_compat_flag
(0 B)
๐
network_config
(86 B)
๐
pwd_info_config
(1 B)
๐
redhat_vmconfig.sh
(17.93 KB)
๐
reset_duid_config
(21 B)
๐
sangfor_guest_datareport
(25.63 KB)
๐
sangfor_heartalive.sh
(2.37 KB)
๐
sangfor_module_update
(28.11 KB)
๐
sangfor_set_network.sh
(504 B)
๐
sangfor_sfping
(4.23 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
(3.55 KB)
๐
sangfor_vmconfig_common
(38.34 KB)
๐
sangfor_vmconfig_ipc_callback
(4.75 KB)
๐
sangfor_watchdog
(3.95 KB)
๐
sfping
(17.7 KB)
๐
sfping.pl
(8.57 KB)
๐
startall
(1.78 KB)
๐
stopall
(1.11 KB)
๐
suse_vmconfig.sh
(10.07 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
(33.63 KB)
๐
update_network.flag
(1 B)
๐
virtio_nic_attr_set.sh
(2.42 KB)
๐
virtio_nic_compat.sh.old1610337499
(5.64 KB)
๐
vm_ip_recover.sh
(16.66 KB)
๐
vm_ipc.sh
(9.06 KB)
๐
vmconfig_common_func
(23.11 KB)
๐
vmconfig_common_header
(3.37 KB)
๐
vmconfig_config
(1.02 KB)
๐
vmtools-install.sh
(31.16 KB)
๐
watch_test.sh
(313 B)
๐
watchdog.sh
(1.39 KB)
๐
x64
๐
x86
Editing: sangfor_module_update
#!/bin/bash shell_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) . "${shell_dir}/update_config" . "${shell_dir}/action_common.sh" . "${shell_dir}/vm_ipc.sh" . "${shell_dir}/update_common_header" . "${shell_dir}/update_common_func" . "${shell_dir}/watchdog.sh" . "${shell_dir}/vm_ip_recover.sh" . "${shell_dir}/guest_system_config.sh" #0 is true ,1 is false #current directory declare g_current_dir="" #temp directory declare g_temp_dir="" #install directory declare g_install_path="" #update now declare g_update_now=0 #update after service start 5min the first time declare g_update_first_time=1 # get field function # $1 The XML string # $2 The field string # return :Get the filed string. return g_ERROR if failed! get_field_info(){ local xml_str="$1" local field_name="$2" local temp_str="" local temp_str_str="" if [ x"${xml_str}" = x"" -o x"${field_name}" = x"" ];then log_error "get_field_info:args is error" echo "${g_ERROR}" return fi temp_str=`echo "${xml_str}" 2>/dev/null |grep -o "<${field_name}>.*</${field_name}>"` if [ x"${temp_str}" = x"" ];then log_warn "can not find field:${field_name}" echo "" return fi temp_str="${xml_str#*<${field_name}>}" temp_str_str="${temp_str%%</${field_name}>*}" echo "${temp_str_str}" return } #TEST get_field_info function TEST_get_field_info(){ log_debug "TEST_get_field_info" if [ "$(get_field_info "${xml_str}" )" != "${g_ERROR}" ];then log_error "get_field_info ${xml_str} failed!" log_error "TEST_get_field_info failed!" return 1 fi log_debug "$(get_field_info "${ModuleName}")" if [ "$(get_field_info "${ModuleName}" )" != "${g_ERROR}" ];then log_error "get_field_info ${ModuleName} failed!" log_error "TEST_get_field_info failed!" return 1 fi local xml_str="\ <?xml version="1.0" encoding="utf-8"?>\ <root>\ <linux_module>\ <ModuleName>LinuxModulesUpdate</ModuleName>\ <ModuleType>SERVER</ModuleType>\ <Promote>0</Promote>\ <Version>2.1.0</Version>\ <PackageDir></PackageDir>\ <Dependence></Dependence>\ <UnstallPath></UnstallPath>\ <UnstallArgs></UnstallArgs>\ <InstallPath>install.sh</InstallPath>\ <InstallArgs></InstallArgs>\ <MD5>md5</MD5>\ <UpdateResult></UpdateResult>\ <UnstallResult></UnstallResult>\ <InstallResult></InstallResult>\ </linux_module>\ </root>\ " log_debug "$(get_field_info "${xml_str}" "${ModuleName}")" log_debug "$(get_field_info "${xml_str}" "${ModuleType}")" log_debug "$(get_field_info "${xml_str}" "${Promote}")" log_debug "$(get_field_info "${xml_str}" "${Version}")" log_debug "$(get_field_info "${xml_str}" "${PackageDir}")" log_debug "$(get_field_info "${xml_str}" "${Dependence}")" log_debug "$(get_field_info "${xml_str}" "${UnstallPath}")" log_debug "$(get_field_info "${xml_str}" "${UnstallArgs}")" log_debug "$(get_field_info "${xml_str}" "${InstallPath}")" log_debug "$(get_field_info "${xml_str}" "${InstallArgs}")" log_debug "$(get_field_info "${xml_str}" "${MD5}")" log_debug "$(get_field_info "${xml_str}" "${UpdateResult}")" log_debug "$(get_field_info "${xml_str}" "${UnstallResult}")" log_debug "$(get_field_info "${xml_str}" "${InstallResult}")" xml_str="\ <?xml version="1.0" encoding="utf-8"?>\ <root>\ <linux_module>\ <ModuleName >LinuxModulesUpdate</ModuleName>\ <ModuleType>SERVER/ModuleType>\ <Promote>0</Promote>\ <Version>2.1.0</Version>\ <PackageDir></PackageDir>\ <Dependence></Dependence>\ <UnstallPath></UnstallPath>\ <UnstallArgs></UnstallArgs>\ <InstallPath>install.sh</InstallPath>\ </InstallArgs>\ <MD5>md5</MD5>\ <MD5>md5</MD5>\ <UpdateResult></UpdateResult>\ <UnstallResult></UnstallResult>\ <InstallResult></InstallResult>\ </linux_module>\ </root>\ " log_debug "$(get_field_info "${xml_str}" "${ModuleName}")" log_debug "$(get_field_info "${xml_str}" "${ModuleType}")" log_debug "$(get_field_info "${xml_str}" "${Promote}")" log_debug "$(get_field_info "${xml_str}" "${Version}")" log_debug "$(get_field_info "${xml_str}" "${PackageDir}")" log_debug "$(get_field_info "${xml_str}" "${Dependence}")" log_debug "$(get_field_info "${xml_str}" "${UnstallPath}")" log_debug "$(get_field_info "${xml_str}" "${UnstallArgs}")" log_debug "$(get_field_info "${xml_str}" "${InstallPath}")" log_debug "$(get_field_info "${xml_str}" "${InstallArgs}")" log_debug "$(get_field_info "${xml_str}" "${MD5}")" log_debug "$(get_field_info "${xml_str}" "${UpdateResult}")" log_debug "$(get_field_info "${xml_str}" "${UnstallResult}")" log_debug "$(get_field_info "${xml_str}" "${InstallResult}")" } # Get file function # $1 The file name in the host # $2 The file path to save in the guest # return 0 is success and 1 is failed get_file(){ if [ $# -ne 2 ];then log_error "argments is error!" return 1 fi test -z "${g_temp_dir}" && return 1 test -z "${g_get_file_flag}" && return 1 local file_name="$1" local save_file_path="$2" local exit_code=1 log_debug "get_file:file_name:${file_name}" log_debug "get_file:save_file_path:${save_file_path}" #init local request_get_file_data_header="${g_header_json}" local request_get_file_data_json="${g_file_data_request_json}" #assign request_get_file_data_header="${request_get_file_data_header/"${g_replace_version_name}"/8208}" request_get_file_data_header="${request_get_file_data_header/"${g_replace_type_name}"/${MESSAGE_TYPE__MESSAGE_FILEDATA_REQ_LINUX}}" request_get_file_data_header="${request_get_file_data_header/"${g_replace_number_name}"/0}" request_get_file_data_header="${request_get_file_data_header/"${g_replace_response_packages_name}"/0}" log_debug "request_get_file_data_header:${request_get_file_data_header}" request_get_file_data_json="${request_get_file_data_json/"${g_replace_header_name}"/${request_get_file_data_header}}" request_get_file_data_json="${request_get_file_data_json/"${g_replace_filename_name}"/${file_name}}" request_get_file_data_json="${request_get_file_data_json/"${g_replace_offset_name}"/0}" log_debug "request_get_file_data_json:${request_get_file_data_json}" #send request vm_ipc_to_local_host ${g_mode_id} ${g_instance_id} ${MESSAGE_TYPE__MESSAGE_FILEDATA_REQ_LINUX} "${request_get_file_data_json}" || return 1 local time_out=${g_time_out} local use_time=0 while [ ! -e "${g_temp_dir}/${g_get_file_flag}" ] do log_debug "${g_temp_dir}/${g_get_file_flag} not exist!" if [ ${use_time} -ge ${time_out} ];then log_warn "get file time out!" break; fi sleep 1 use_time=$((use_time+1)) done if [ ! -e "${g_temp_dir}/${g_get_file_flag}" ];then log_error "get file:${file_name} failed!" return 1 fi log_debug "${g_temp_dir}/${g_get_file_flag} exist!" mv -f "${g_temp_dir}/${g_save_file_temp_name}" "${save_file_path}" >/dev/null 2>&1 exit_code=$? rm -f "${g_temp_dir}/${g_get_file_flag}" 2>/dev/null if [ $? -ne 0 ];then log_warn "get_file:rm -f ${g_temp_dir}/${g_get_file_flag} failed!" fi if [ ${exit_code} -ne 0 ];then log_error "get_file:move file failed!src file is:${g_temp_dir}/${g_save_file_temp_name} des file is:${save_file_path}" return 1 fi return 0 } #TEST get_file TEST_get_file(){ #g_temp_dir="/home/lzw/temp" log_debug "TEST_get_file" get_file "${g_xml_file_name}" "${g_temp_dir}/${g_xml_file_name}" if [ ! -f "${g_temp_dir}/${g_xml_file_name}" ];then log_error "${g_temp_dir}/${g_xml_file_name} is not exist!" log_error "TEST_get_file failed!" return 1 fi return 0 } #Get file size #$1 The file name in the host #return 0 is true and 1 is false #echo The file size # get_file_size_request(){ # #send a request # local file_name="$1" # if [ x"${file_name}" = x"" ];then # log_error "get_file_size:argment is NULL!" # return 1 # fi # #init # local request_get_file_info_header="${g_header_json}" # local request_get_file_info_json="${g_file_info_request_json}" # #assign # request_get_file_info_header="${request_get_file_info_header/"${g_replace_version_name}"/8208}" # request_get_file_info_header="${request_get_file_info_header/"${g_replace_type_name}"/1011}" # request_get_file_info_header="${request_get_file_info_header/"${g_replace_number_name}"/0}" # request_get_file_info_header="${request_get_file_info_header/"${g_replace_response_packages_name}"/0}" # log_info "request_get_file_info_header:${request_get_file_info_header}" # request_get_file_info_json="${request_get_file_info_json/"${g_replace_header_name}"/${request_get_file_info_header}}" # request_get_file_info_json="${request_get_file_info_json/"${g_replace_filename_name}"/Update.XML}" # log_info "request_get_file_info_json:${request_get_file_info_json}" # #send request # vm_ipc_to_local_host ${modid} ${instid} 1011 "${request_get_file_info_json}" || return 1 # ###### # return 0 # } # #TEST get_file_size_request # TEST_get_file_size_request(){ # return # } #Get XML file #return 0 is true and 1 is failed get_xml_file(){ local exit_code=1 get_file "${g_xml_file_name}" "${g_temp_dir}/${g_xml_file_name}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "get_xml_file failed!" return 1 fi return 0 } #TEST get_xml_file TEST_get_xml_file(){ log_debug "TEST_get_xml_file" get_xml_file if [ ! -e "${g_temp_dir}/${g_xml_file_name}" ];then log_error "TEST_get_xml_file failed!" return 1 fi return 0 } #check update function #$1 The XML file in the guest. #$2 The XML file geted from host. #0 With the upgrade #1 Without the upgrade check_update(){ local check_result=1; local temp_str="" local temp_str_str="" local host_version="" local local_version="" if [ $# -ne 2 ];then log_error "argments is error!" return 1 fi #The xml file in the guest. local local_xml_file="$1" #The xml file geted from host. local host_xml_file="$2" temp_str=`cat "${host_xml_file}" 2>/dev/null |grep "${g_update_mode_name}" 2>/dev/null` #Determine the parameters of legitimacy if [ x"${temp_str}" = x"" ];then #The xml file in the host is wrong. log_error "host xml file is error!" return 1 fi log_debug "local_xml_file:${local_xml_file}" log_debug "host_xml_file:${host_xml_file}" temp_str=`cat "${local_xml_file}" 2>/dev/null |grep "${Version}" 2>/dev/null` temp_str_str=${temp_str#*<${Version}>} local_version=${temp_str_str%%</${Version}>*} temp_str=`cat "${host_xml_file}" 2>/dev/null |grep "${Version}" 2>/dev/null` temp_str_str=${temp_str#*<${Version}>} host_version=${temp_str_str%%</${Version}>*} log_debug "local_version:${local_version}" log_debug "host_version:${host_version}" if [ x"${local_version}" = x"" ];then # The xml file in the guest is wrong, so update to repair. log_warn "guest xml file version field is error.update to corrent!" return 0 fi if [ x"${host_version}" = x"" ];then log_warn "host xml file version field is error!" return 1 fi compare_version "${local_version}" "${host_version}" >/dev/null 2>&1 check_result=$? log_debug "compare_version return:${check_result}" #To update if the xml file in host is more new. if [ ${check_result} -eq 2 ];then return 0 fi return 1 } #TEST check_update TEST_check_update(){ log_debug "TEST_check_update" local xml_str="\ <?xml version="1.0" encoding="utf-8"?>\ <root>\ <linux_module>\ <ModuleName>VMOptimizationToolsLinux</ModuleName>\ <ModuleType>SERVER</ModuleType>\ <Promote>0</Promote>\ <Version>2.1.0</Version>\ <PackageDir></PackageDir>\ <Dependence></Dependence>\ <UnstallPath></UnstallPath>\ <UnstallArgs></UnstallArgs>\ <InstallPath>install.sh</InstallPath>\ <InstallArgs></InstallArgs>\ <MD5>md5</MD5>\ <UpdateResult></UpdateResult>\ <UnstallResult></UnstallResult>\ <InstallResult></InstallResult>\ </linux_module>\ </root>\ " echo "${xml_str}" > "${g_temp_dir}/TEST_check_update.XML" echo "${xml_str}" > "${g_temp_dir}/TEST_check_update_new.XML" check_update "${g_temp_dir}/TEST_check_update.XML" "${g_temp_dir}/TEST_check_update_new.XML" if [ $? -ne 1 ];then log_error "check_update ${g_temp_dir}/TEST_check_update.XML ${g_temp_dir}/TEST_check_update_new.XML failed! " log_error "TEST_compare_version failed!" return 1 fi echo "${xml_str/2.1.0/2.1.1}" > "${g_temp_dir}/TEST_check_update_new.XML" check_update "${g_temp_dir}/TEST_check_update.XML" "${g_temp_dir}/TEST_check_update_new.XML" if [ $? -ne 0 ];then log_error "check_update ${g_temp_dir}/TEST_check_update.XML ${g_temp_dir}/TEST_check_update_new.XML failed!" log_error "TEST_compare_version failed!" return 1 fi check_update "${g_temp_dir}/TEST_check_update.XML" if [ $? -ne 1 ];then log_error "check_update ${g_temp_dir}/TEST_check_update.XML failed!" log_error "TEST_compare_version failed!" return 1 fi echo "${xml_str/2.1.0/}" > "${g_temp_dir}/TEST_check_update_new.XML" check_update "${g_temp_dir}/TEST_check_update.XML" "${g_temp_dir}/TEST_check_update_new.XML" if [ $? -ne 1 ];then log_error "check_update ${g_temp_dir}/TEST_check_update.XML ${g_temp_dir}/TEST_check_update_new.XML failed!" log_error "TEST_compare_version failed!" return 1 fi echo "${xml_str/2.1.0/}" > "${g_temp_dir}/TEST_check_update.XML" check_update "${g_temp_dir}/TEST_check_update.XML" "${g_temp_dir}/TEST_check_update_new.XML" if [ $? -ne 0 ];then log_error "check_update ${g_temp_dir}/TEST_check_update.XML ${g_temp_dir}/TEST_check_update_new.XML failed!" log_error "TEST_compare_version failed!" return 1 fi return 0 } #Get the install archive. #$1 The archive file name without the suffix name. #filed 1 #success 0 get_install_archive(){ local archive_name="$1" local exit_code=1 if [ x"${archive_name}" = x"" ];then return 1 fi #Get file from host. get_file "${archive_name}.${g_archive_ext}" "${g_temp_dir}/${archive_name}.${g_archive_ext}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "get_install_archive failed!" return 1 fi return 0 } #TEST get_install_archive TEST_get_install_archive(){ log_debug "TEST_get_install_archive" get_install_archive "${g_update_mode_name}" if [ $? -ne 0 ];then log_error "get_install_archive ${g_update_mode_name} failed!" log_error "TEST_get_install_archive failed!" return 1 fi return 0 } #Decompression the tar archive. #$1 The Path of the tar archive. #$2 The directory to decompress. #failed 1 #success 0 untar(){ local archive_path="$1" local to_dir="$2" local exit_code=1 if [ $# -ne 2 ];then log_error "argments is error! archive_path:${archive_path}. to_dir:${to_dir}." return 1 fi if [ -e "${to_dir}" ];then if [ -d "${to_dir}" ];then log_info "untar to dir is already exist." else log_error "untar to dir is exist but it is not a directory!" return 1 fi else create_dir "${to_dir}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "create directory failed! dir is:${to_dir}" return 1 fi fi tar -xzf "${archive_path}" -C "${to_dir}" 2>/dev/null exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "untar failed! archive_path:${archive_path}. to_dir:${to_dir}." return 1 fi return 0 } #TEST untar TEST_untar(){ log_debug "TEST_untar" tar -czf "${g_temp_dir}/test.tar.gz" "/usr/bin/tar" untar "${g_temp_dir}/test.tar.gz" "${g_temp_dir}/test" if [ $? -ne 0 ];then log_error "untar ${g_temp_dir}/test.tar.gz ${g_temp_dir}/test" log_error "TEST_untar failed!" rm -rf "${g_temp_dir}/test.tar.gz" rm -rf "${g_temp_dir}/test" return 1 fi rm -rf "${g_temp_dir}/test.tar.gz" rm -rf "${g_temp_dir}/test" return 0 } #Get the current directory. #failed 1 #success 0 get_current_dir(){ # g_current_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) g_current_dir="${shell_dir}" if [ x"${g_current_dir}" = x"" ];then log_error "get_current_dir() failed!" return 1 fi return 0 } #TEST get_current_dir TEST_get_current_dir(){ log_debug "TEST_get_current_dir" # Print the path to judge the test result. get_current_dir if [ $? -ne 0 ];then log_error "get_current_dir failed! g_current_dir:${g_current_dir}" log_error "TEST_get_current_dir filed!" return 1 fi if [ "${g_current_dir}" != "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ];then log_error "get_current_dir failed! g_current_dir:${g_current_dir}" log_error "TEST_get_current_dir filed!" return 1 fi return 0 } #Init environment. init_env(){ get_current_dir exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "get_current_dir() failed! " return 1 fi #install directory. g_install_path="${g_current_dir}" #temp directory. g_temp_dir="$( cd "${g_current_dir}/../" && pwd )/${g_temp_dir_name}" test -z "${g_current_dir}" && return 1 test -z "${g_install_path}" && return 1 test -z "${g_temp_dir}" && return 1 log_debug "g_temp_dir:${g_temp_dir}" create_dir "${g_temp_dir}" return 0 } #TEST init_env TEST_init_env(){ log_debug "TEST_init_env" init_env # Print the path to judge the test result. log_debug "g_current_dir:${g_current_dir}" log_debug "g_install_path:${g_install_path}" log_debug "g_temp_dir:${g_temp_dir}" if [ "${g_current_dir}" != "${g_install_path}" ];then log_error "g_current_dir != g_install_path" return 1 fi if [ ! -d "${g_temp_dir}" ];then log_error "${g_temp_dir} is not a dir!" return 1 fi if [ "${g_current_dir}" != "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ];then log_error "get_current_dir failed! g_current_dir:${g_current_dir}" log_error "TEST_get_current_dir filed!" return 1 fi return 0 } #Update the xml file. #$1 The path of the xml file geted from host. #$2 The module name to update. #success 0 #failed 1 update_xml_file(){ local host_xml_file="$1" local module_name="$2" local exit_code=1 log_info "host_xml_file=${host_xml_file}" log_info "module_name=${module_name}" # Replace the xml file to update. cp -f "${host_xml_file}" "${g_install_path}/${g_xml_file_name}" 2>/dev/null exit_code=$? if [ ${exit_code} -eq 0 ];then log_info "update XML file success." return 0 fi log_error "update XML file failed!" return 1 } #TEST update_xml_file TEST_update_xml_file(){ return 0 } #upgrade slef #failed 1 #success 0 self_update(){ local host_md5="" local compare_md5="" local install_path="" local install_args="" local index=0 host_md5="$(get_field_info "$(cat "${g_temp_dir}/${g_xml_file_name}")" "${MD5}")" log_info "xml md5 is:${host_md5}" #Check the length of the md5 string. if [ ${#host_md5} -ne 32 ];then log_error "host md5 length is not 32!" return 1 fi local exit_code=1 for((index=0;index<3;index++)) do get_install_archive "${g_update_mode_name}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "get ${g_module_update_archive_name} install archive failed!" continue fi compare_md5="" compare_md5=`md5sum "${g_temp_dir}/${g_module_update_archive_name}" 2>/dev/null | awk -F ' ' '{print $1}' | tr -d [:space:] | tr [a-z] [A-Z]` #Compare md5 string,case-insensitive host_md5=`echo "${host_md5}" 2>/dev/null | tr -d [:space:] | tr [a-z] [A-Z]` log_info "compare_md5:${compare_md5}" log_info "host_md5:${host_md5}" if [ x"${compare_md5}" = x"${host_md5}" ];then break; fi log_error "md5 is not equal!" continue done if [ ${index} -eq 3 ];then log_error "get ${g_module_update_archive_name} failed!" return 1 fi #Downloal file success. #Untar the tar archive. untar "${g_temp_dir}/${g_module_update_archive_name}" "${g_temp_dir}/${g_update_mode_name}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "untar ${g_temp_dir}/${g_module_update_archive_name} failed!" return 1 fi install_path="${g_temp_dir}/${g_update_mode_name}/$(get_field_info "$(cat "${g_temp_dir}/${g_xml_file_name}")" "${InstallPath}")" install_args="$(get_field_info "$(cat "${g_temp_dir}/${g_xml_file_name}")" "${InstallArgs}")" if [ ! -e "${install_path}" ];then log_error "${install_path} is not exist!" return 1 fi chmod +x "${install_path}" 2>/dev/null "${install_path}" "${install_args}" exit_code=$? if [ ${exit_code} -eq 0 ];then log_info "run ${install_path} ${install_args} success!" return 0 fi #Update self failed. log_error "run ${install_path} ${install_args} failed!" return 1 } #TEST self_update TEST_self_update(){ return 0 } #update module module_update(){ local exit_code=1; #Clean the environment test -z "${g_temp_dir}" && return rm -rf "${g_temp_dir}"/* 2>/dev/null create_dir "${g_temp_dir}" #Download the XML file. get_xml_file exit_code=$? if [ ${exit_code} -eq 1 ];then log_error "get_xml_file failed!" return fi log_debug "get_xml_file success!" #Check the update. check_update "${g_install_path}/${g_xml_file_name}" "${g_temp_dir}/${g_xml_file_name}" exit_code=$? if [ ${exit_code} -eq 1 ];then log_info "no update." return fi #To update #check_self_update # exit_code=$? # Only self update. log_info "It is self update." self_update exit_code=$? if [ ${exit_code} -eq 0 ];then log_info "self update success." #To update XML file # The XML file exist in the archive. So keep it simple. return fi #Update self failed. log_error "self update failed!" return } #TEST module_update TEST_module_update(){ return 0 } #trap kill signal signal_term(){ log_warn "SIGTERM signal,exit..." kill_process "${g_update_callback_shell_file}" log_debug "kill ${g_update_callback_shell_file}" exit 1 } #trap int signal signal_int(){ log_warn "INT signal,exit..." kill_process "${g_update_callback_shell_file}" log_debug "kill ${g_update_callback_shell_file}" exit 1 } signal_usr1(){ log_debug "To update now!" g_update_now=1 } main(){ local has_modify_guest_config = 0 local exit_code=1; set_log_filepath "${g_sangfor_log_dir}/${g_update_shell_name}.log" trap signal_term SIGTERM trap signal_int SIGINT trap signal_usr1 SIGUSR1 kill_process "${g_update_shell_name}" kill_process "${g_update_callback_shell_file}" #watch watchdog_reg_proccess "${g_update_shell_name}" #init environment init_env if [ $? -ne 0 ]; then log_error "init_env failed!" return 1 fi vm_ipc_init ${g_mode_id} ${g_instance_id} if [ $? -ne 0 ]; then log_error "vm_ipc_init() failed! modid='${g_mode_id}' instid='${g_instance_id}'" return 1 fi set_log_filepath "${g_sangfor_log_dir}/${g_update_shell_name}.log" # vm_ipc_reg_callback 103 respond_callback "${g_current_dir}/${g_update_callback_shell_file}" & # background loop # update vmtools while server start for aCMP set password log_info "module update while server start" module_update #ๆๅกๅฏๅจ,็ฆ็จLinux็page migrationๅnuma_balancing modify_guest_system_config #Check update. while true do #Fix TD 91672๏ผvvmwareๅฎ่ฃ ไบ่ๆๅๅทฅๅ ทไนๅ่ฟ็งปๅฐ่ถ ่ๅไผ่ฟ่กIPๆขๅค๏ผ่ฟไธชๅ้กต้ข็ผ่พ่ฎพ็ฝฎIPๅฒ็ชใ่ฎจ่ฎบ่ฟไธชๅ่ฝๅทฒ็ปไธ็จ๏ผๆไปฅ่ฟ้ๆณจ้ๆ :<<EOF # start ip recover check log_info "start to check ip recover ..." if [[ ! -e $g_nic_info_file ]]; then log_debug "nic info file: $g_nic_info_file not exist, try build" build_nic_info_file if [[ $? -ne 0 ]]; then log_error "build_nic_info_file failed" fi fi local need_recover=$(need_ip_recover) if [[ $? -ne 0 ]]; then log_error "func need_ip_recover failed" fi if [[ $need_recover == 'yes' ]]; then log_debug "need ip recover" ip_recover if [[ $? -ne 0 ]]; then log_error "ip recover failed" fi fi build_nic_info_file if [[ $? -ne 0 ]]; then log_error "buld_nic_info_file failed" fi # end ip recover check EOF local sleep_time=0 for((sleep_time=0;sleep_time<${g_check_update_time};sleep_time+=5)) do if [ ${g_update_now} -eq 1 ];then g_update_now=0 break fi if [ ${g_update_first_time} -eq 1 ] && [ ${sleep_time} -eq ${g_check_update_first_time} ]; then g_update_first_time=0 break fi sleep 5 done #ๆๅกๅฏๅจ g_check_update_first_time (5ๅ้)ไนๅๆๅป่ฎพ็ฝฎ่ๆๆบ็ณป็ป้ ็ฝฎ,ๅฆ่ sysctl.conf็้ ็ฝฎไผ่ฆ็ๆไปฌ็ไฟฎๆน if [[ $has_modify_guest_config -eq 0 ]]; then #Fix TD 86851, 5ๅ้ๅ็ฆ็จไธๆฌกLinux็page migrationๅnuma_balancing๏ผ้ฒๆญข็ณป็ปsysctl.conf้ ็ฝฎ่ฆ็ๆไปฌๅ้ข็่ฎพ็ฝฎ modify_guest_system_config has_modify_guest_config = 1 fi log_info "start to check update..." module_update watchdog_check_once done log_info "exit all." exit 0 } TEST(){ # All of the file should saved in the install directory to test. # Test will filed if you don't. set_log_filepath "${g_sangfor_log_dir}/${g_update_shell_name}.log" TEST_init_env || return 1 # TEST_init_env and to init the environment. vm_ipc_init ${g_mode_id} ${g_instance_id} if [ $? -ne 0 ]; then log_error "vm_ipc_init() failed! modid='${g_mode_id}' instid='${g_instance_id}'" return 1 fi set_log_filepath "${g_sangfor_log_dir}/${g_update_shell_name}.log" # TEST_create_dir || return 1 TEST_get_current_dir || return 1 TEST_get_field_info || return 1 TEST_get_major || return 1 TEST_get_minor || return 1 TEST_get_release || return 1 TEST_compare_version || return 1 TEST_check_update || return 1 TEST_untar || return 1 # Start vm_proxyd and update_callback to test download file. "${g_install_path}/${g_vm_proxyd_shell_name}" & 2>/dev/null "${g_install_path}/${g_update_callback_shell_file}" & 2>/dev/null TEST_get_file || return 1 TEST_get_xml_file || return 1 TEST_get_install_archive || return 1 # Clean environment after test successed. local service_name="" for service_name in ${g_sangfor_services[@]} do watchdog_unreg_process "${service_name}" log_debug "watchdog_unreg_process ${service_name}" done kill_process "${g_update_callback_shell_file}" kill_process "${g_vm_proxyd_shell_name}" kill_process "${g_watchdog_shell_file}" log_debug "TEST all success!" rm -rf "${g_temp_dir}" log_debug "rm -rf ${g_temp_dir}" return 0 } if [ "${1}" = "TEST" ];then TEST exit $? else main exit $? fi
Upload File
Create Folder