[ agent ] [ agent ] - agent bootup optimize
This commit is contained in:
@@ -6,6 +6,7 @@ import io.wdd.agent.executor.thread.LogToArrayListCache;
|
||||
import io.wdd.common.beans.executor.ExecutionMessage;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -86,12 +87,17 @@ public class CommandExecutor {
|
||||
// start to send the result log
|
||||
streamSender.startToWaitLog(streamKey);
|
||||
|
||||
// get the command result
|
||||
processResult = process.waitFor();
|
||||
// get the command result must also be a timeout smaller than the process
|
||||
boolean waitFor = process.waitFor(processMaxWaitSeconds, TimeUnit.SECONDS);
|
||||
|
||||
// end send logs
|
||||
streamSender.endWaitLog(streamKey);
|
||||
|
||||
// get the process result
|
||||
if (ObjectUtils.isNotEmpty(waitFor) && ObjectUtils.isNotEmpty(process)) {
|
||||
processResult = process.exitValue();
|
||||
}
|
||||
|
||||
log.debug("current shell command {} result is {}", processBuilder.command(), processResult);
|
||||
|
||||
|
||||
@@ -106,7 +112,6 @@ public class CommandExecutor {
|
||||
return () -> {
|
||||
try {
|
||||
|
||||
|
||||
log.debug("daemon thread start to wait for {} s for the result", processMaxWaitSeconds);
|
||||
|
||||
TimeUnit.SECONDS.sleep(processMaxWaitSeconds);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CollectAllExecutorFunction {
|
||||
|
||||
|
||||
/**
|
||||
* store the Octopus Agent Functions and Reflection Class Path
|
||||
* store the Octopus Agent Functions and Function Command List
|
||||
* key: function name
|
||||
* value: function shell List<String> contend
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
##### environment variables ######
|
||||
|
||||
|
||||
JAVA_OPTS="-Xms128m -Xmx512m -Dfile.encoding=utf-8 --spring.profiles.active=k3s --spring.cloud.nacos.config.group=k3s --spring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml --spring.cloud.nacos.config.extension-configs[0].group=k3s"
|
||||
|
||||
DependLibFiles=(
|
||||
@@ -41,6 +40,15 @@ colorEcho() {
|
||||
echo -e "\033[${1}${@:2}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# EUID
|
||||
# RED
|
||||
# YELLOW
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
check_root() {
|
||||
if [[ $EUID != 0 ]]; then
|
||||
colorEcho ${RED} "当前非root账号(或没有root权限),无法继续操作,请更换root账号!"
|
||||
@@ -49,17 +57,41 @@ check_root() {
|
||||
fi
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# PURPLE
|
||||
# SplitLine
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
FunctionStart() {
|
||||
colorEcho ${PURPLE} ${SplitLine}
|
||||
colorEcho ${PURPLE} ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# GREEN
|
||||
# SplitLine
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
FunctionSuccess() {
|
||||
colorEcho ${GREEN} ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BlinkGreen
|
||||
# SplitLine
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
FunctionEnd() {
|
||||
echo ""
|
||||
colorEcho ${BlinkGreen} ${SplitLine}
|
||||
@@ -79,32 +111,32 @@ check_sys() {
|
||||
|
||||
sys_bit=$(uname -m)
|
||||
case $sys_bit in
|
||||
i[36]86)
|
||||
os_bit="32"
|
||||
LinuxRelease="386"
|
||||
;;
|
||||
x86_64)
|
||||
os_bit="64"
|
||||
LinuxRelease="amd64"
|
||||
;;
|
||||
*armv6*)
|
||||
os_bit="arm"
|
||||
LinuxRelease="arm6"
|
||||
;;
|
||||
*armv7*)
|
||||
os_bit="arm"
|
||||
LinuxRelease="arm7"
|
||||
;;
|
||||
*aarch64* | *armv8*)
|
||||
os_bit="arm64"
|
||||
LinuxRelease="arm64"
|
||||
;;
|
||||
*)
|
||||
colorEcho ${RED} "
|
||||
i[36]86)
|
||||
os_bit="32"
|
||||
LinuxRelease="386"
|
||||
;;
|
||||
x86_64)
|
||||
os_bit="64"
|
||||
LinuxRelease="amd64"
|
||||
;;
|
||||
*armv6*)
|
||||
os_bit="arm"
|
||||
LinuxRelease="arm6"
|
||||
;;
|
||||
*armv7*)
|
||||
os_bit="arm"
|
||||
LinuxRelease="arm7"
|
||||
;;
|
||||
*aarch64* | *armv8*)
|
||||
os_bit="arm64"
|
||||
LinuxRelease="arm64"
|
||||
;;
|
||||
*)
|
||||
colorEcho ${RED} "
|
||||
哈哈……这个 辣鸡脚本 不支持你的系统。 (-_-) \n
|
||||
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
|
||||
" && exit 1
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
## 判定Linux的发行版本
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
@@ -187,6 +219,18 @@ installDemandSoftwares() {
|
||||
return 0
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# DependLibFiles
|
||||
# OctopusAgentPath
|
||||
# RED
|
||||
# RepoSourcePath
|
||||
# libfile
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
DownloadAllFile() {
|
||||
|
||||
FunctionStart
|
||||
@@ -202,7 +246,7 @@ DownloadAllFile() {
|
||||
for libfile in ${DependLibFiles[*]}; do
|
||||
|
||||
colorEcho $BLUE "lib file is $libfile"
|
||||
wget "$RepoSourcePath/lib/$libfile" -Oq $OctopusAgentPath/lib/$libfile
|
||||
wget "$RepoSourcePath/lib/$libfile" -qO $OctopusAgentPath/lib/$libfile
|
||||
FunctionSuccess
|
||||
|
||||
done
|
||||
@@ -220,8 +264,15 @@ DownloadAllFile() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ModifySystemConfig(){
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# GREEN
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
ModifySystemConfig() {
|
||||
FunctionStart
|
||||
|
||||
colorEcho ${BLUE} "开始修改系统内核参数…………"
|
||||
@@ -236,13 +287,20 @@ EOF
|
||||
colorEcho ${GREEN} "--------------系统内核参数修改的结果如上所示----------------"
|
||||
FunctionSuccess
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# JDK_VERSION
|
||||
# LinuxReleaseVersion
|
||||
# Arguments:
|
||||
# 1
|
||||
#######################################
|
||||
InstallJDKPackage() {
|
||||
JDK_VERSION="11"
|
||||
if [[ "$1" -ne " " ]]; then
|
||||
if [[ $1 -ne " " ]]; then
|
||||
JDK_VERSION="$1"
|
||||
echo "JDK Version = ${JDK_VERSION}"
|
||||
fi
|
||||
@@ -250,7 +308,7 @@ InstallJDKPackage() {
|
||||
echo "InstallJDK from package management !"
|
||||
echo ""
|
||||
|
||||
if [[ "${LinuxReleaseVersion}" == "centos" ]]; then
|
||||
if [[ ${LinuxReleaseVersion} == "centos" ]]; then
|
||||
colorEcho ${BLUE} "当前系统发行版为 centos !"
|
||||
colorEcho ${BLUE} "可以安装的 openjdk 版本为:"
|
||||
yum list java-${JDK_VERSION}-openjdk | grep ${JDK_VERSION}
|
||||
@@ -273,7 +331,14 @@ InstallJDKPackage() {
|
||||
|
||||
}
|
||||
|
||||
systemdAgent(){
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# JAVA_OPTS
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
systemdAgent() {
|
||||
|
||||
# https://www.baeldung.com/linux/run-java-application-as-service
|
||||
|
||||
@@ -297,15 +362,15 @@ ExecStop=/bin/kill -15 \$MAINPID
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# https://www.benzhu.xyz/linux12/
|
||||
cat >/etc/rsyslog.d/octopus-agent.conf <<EOF
|
||||
# https://www.benzhu.xyz/linux12/
|
||||
cat >/etc/rsyslog.d/octopus-agent.conf <<EOF
|
||||
if \$programname == 'octopus-agent' then /var/log/octopus-agent.log
|
||||
& stop
|
||||
EOF
|
||||
|
||||
rsyslogd -N1 -f /etc/rsyslog.d/octopus-agent.conf
|
||||
rsyslogd -N1 -f /etc/rsyslog.d/octopus-agent.conf
|
||||
|
||||
systemctl restart rsyslog
|
||||
systemctl restart rsyslog
|
||||
}
|
||||
|
||||
## 为了本脚本能够满足Ubuntu系统,做出设当的更改
|
||||
@@ -327,8 +392,15 @@ CommonToolInstall() {
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
|
||||
BootUPAgent(){
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# OctopusAgentPath
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
BootUPAgent() {
|
||||
|
||||
FunctionStart
|
||||
|
||||
@@ -345,34 +417,45 @@ BootUPAgent(){
|
||||
systemctl enable octopus-agent.service
|
||||
systemctl start octopus-agent.service
|
||||
|
||||
#
|
||||
# systemctl restart octopus-agent.service
|
||||
# systemctl status octopus-agent.service -l
|
||||
#tail -f 500 /var/log/octopus-agent.log
|
||||
#
|
||||
# systemctl restart octopus-agent.service
|
||||
# systemctl status octopus-agent.service -l
|
||||
#tail -f 500 /var/log/octopus-agent.log
|
||||
|
||||
FunctionSuccess
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# RED
|
||||
# i
|
||||
# Arguments:
|
||||
# 1
|
||||
# Returns:
|
||||
# $? ...
|
||||
#######################################
|
||||
InstallZSH() {
|
||||
FunctionStart
|
||||
|
||||
ZSH_SOURCE="us"
|
||||
local ZSH_SOURCE="us"
|
||||
|
||||
if [[ "$1" -ne " " ]]; then
|
||||
ZSH_SOURCE="$1"
|
||||
echo "zsh install source = ${ZSH_SOURCE}"
|
||||
if [[ $1 -ne " " ]]; then
|
||||
ZSH_SOURCE="$1"
|
||||
colorEcho ${BLUE} "zsh install source = ${ZSH_SOURCE}"
|
||||
fi
|
||||
|
||||
colorEcho ${BLUE} "开始安装宇宙第一shell工具zsh……"
|
||||
echo ""
|
||||
|
||||
installDemandSoftwares zsh git || return $?
|
||||
# 脚本会自动更换默认的shell
|
||||
if [[ "${ZSH_SOURCE}" -eq "cn" ]]; then
|
||||
echo y | REMOTE=https://gitee.com/mirrors/oh-my-zsh.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
|
||||
if [[ ${ZSH_SOURCE} -eq "us" ]]; then
|
||||
echo y | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
else
|
||||
echo y | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
echo y | REMOTE=https://gitee.com/mirrors/oh-my-zsh.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
|
||||
fi
|
||||
#echo y | sh -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/robbyrussell/oh-my-zsh@master/tools/install.sh)"
|
||||
echo ""
|
||||
@@ -391,14 +474,24 @@ InstallZSH() {
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# BLUE
|
||||
# GREEN
|
||||
# PURPLE
|
||||
# ZSH_SOURCE
|
||||
# Arguments:
|
||||
# 1
|
||||
#######################################
|
||||
modifyZSH() {
|
||||
FunctionStart
|
||||
|
||||
ZSH_SOURCE="us"
|
||||
|
||||
if [[ "$1" -ne " " ]]; then
|
||||
ZSH_SOURCE="$1"
|
||||
echo "zsh install source = ${ZSH_SOURCE}"
|
||||
if [[ $1 -ne " " ]]; then
|
||||
ZSH_SOURCE="$1"
|
||||
echo "zsh install source = ${ZSH_SOURCE}"
|
||||
fi
|
||||
|
||||
colorEcho ${GREEN} "zsh应该已经安装成功!!!"
|
||||
@@ -412,21 +505,23 @@ EOF
|
||||
colorEcho ${BLUE} "正在下载zsh的一些好用的插件:"
|
||||
echo ""
|
||||
|
||||
if [[ "${ZSH_SOURCE}" -eq "cn" ]]; then
|
||||
colorEcho ${BLUE} "开始从 Gitee 下载 自动补全 插件…………"
|
||||
git clone https://gitee.com/githubClone/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
||||
if [[ ${ZSH_SOURCE} -eq "us" ]]; then
|
||||
colorEcho ${BLUE} "开始从 GitHub 下载 自动补全 插件…………"
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
||||
|
||||
else
|
||||
colorEcho ${BLUE} "开始从 GitHub 下载 自动补全 插件…………"
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
||||
colorEcho ${BLUE} "开始从 Gitee 下载 自动补全 插件…………"
|
||||
git clone https://gitee.com/githubClone/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
||||
fi
|
||||
FunctionSuccess
|
||||
|
||||
if [[ "${ZSH_SOURCE}" -eq "cn" ]]; then
|
||||
colorEcho ${BLUE} "开始从 Gitee 下载 命令高亮 插件…………"
|
||||
git clone https://gitee.com/mo2/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
||||
if [[ ${ZSH_SOURCE} -eq "us" ]]; then
|
||||
colorEcho ${BLUE} "开始从 GitHub 下载 命令高亮 插件…………"
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
||||
|
||||
else
|
||||
colorEcho ${BLUE} "开始从 GitHub 下载 命令高亮 插件…………"
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
||||
colorEcho ${BLUE} "开始从 Gitee 下载 命令高亮 插件…………"
|
||||
git clone https://gitee.com/mo2/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
||||
fi
|
||||
FunctionSuccess
|
||||
|
||||
@@ -463,8 +558,12 @@ EOF
|
||||
FunctionSuccess
|
||||
}
|
||||
|
||||
|
||||
main(){
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
main() {
|
||||
|
||||
check_root
|
||||
check_sys
|
||||
@@ -477,11 +576,10 @@ main(){
|
||||
|
||||
DownloadAllFile
|
||||
|
||||
InstallZSH "us"
|
||||
|
||||
BootUPAgent
|
||||
|
||||
InstallZSH "us"
|
||||
|
||||
}
|
||||
|
||||
|
||||
main
|
||||
main
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||
. /octopus-agent/shell/lib/wdd-lib-sys.sh
|
||||
|
||||
#. .wdd-lib-log.sh
|
||||
#. .wdd-lib-sys.sh
|
||||
|
||||
|
||||
hostArchVersion=""
|
||||
hostArch=""
|
||||
#### CollectSystemInfo ####
|
||||
@@ -41,11 +39,22 @@ city=""
|
||||
org=""
|
||||
#### CollectSystemInfo ####
|
||||
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# 1
|
||||
#######################################
|
||||
GoIOTest() {
|
||||
(LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count=$1 conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# 1
|
||||
# Returns:
|
||||
# <unknown> ...
|
||||
#######################################
|
||||
calc_size() {
|
||||
local raw=$1
|
||||
local total_size=0
|
||||
@@ -72,12 +81,35 @@ calc_size() {
|
||||
echo "${total_size} ${unit}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# <unknown> ...
|
||||
#######################################
|
||||
GethostArchInfo() {
|
||||
[ -f /etc/redhat-release ] && awk '{print $0}' /etc/redhat-release && return
|
||||
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
|
||||
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# freespace
|
||||
# io1
|
||||
# io2
|
||||
# io3
|
||||
# ioall
|
||||
# ioavg
|
||||
# ioraw1
|
||||
# ioraw2
|
||||
# ioraw3
|
||||
# writemb
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
StartIOTest() {
|
||||
log "start IO speed test !"
|
||||
freespace=$(df -m . | awk 'NR==2 {print $4}')
|
||||
@@ -105,12 +137,22 @@ StartIOTest() {
|
||||
echo " $(_red "Not enough space for I/O Speed test!")"
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# cpuName
|
||||
# sys_manu
|
||||
# sys_product
|
||||
# sys_ver
|
||||
# virt
|
||||
# virtualx
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
Check_Virtualization() {
|
||||
|
||||
|
||||
log "start to check host virtualization !"
|
||||
|
||||
command_exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
|
||||
@@ -131,21 +173,21 @@ Check_Virtualization() {
|
||||
virt="LXC"
|
||||
elif [[ -f /proc/user_beancounters ]]; then
|
||||
virt="OpenVZ"
|
||||
elif [[ "${virtualx}" == *kvm-clock* ]]; then
|
||||
elif [[ ${virtualx} == *kvm-clock* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ "${sys_product}" == *KVM* ]]; then
|
||||
elif [[ ${sys_product} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ "${cpuName}" == *KVM* ]]; then
|
||||
elif [[ ${cpuName} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ "${cpuName}" == *QEMU* ]]; then
|
||||
elif [[ ${cpuName} == *QEMU* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ "${virtualx}" == *"VMware Virtual Platform"* ]]; then
|
||||
elif [[ ${virtualx} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ "${sys_product}" == *"VMware Virtual Platform"* ]]; then
|
||||
elif [[ ${sys_product} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ "${virtualx}" == *"Parallels Software International"* ]]; then
|
||||
elif [[ ${virtualx} == *"Parallels Software International"* ]]; then
|
||||
virt="Parallels"
|
||||
elif [[ "${virtualx}" == *VirtualBox* ]]; then
|
||||
elif [[ ${virtualx} == *VirtualBox* ]]; then
|
||||
virt="VirtualBox"
|
||||
elif [[ -e /proc/xen ]]; then
|
||||
if grep -q "control_d" "/proc/xen/capabilities" 2>/dev/null; then
|
||||
@@ -155,9 +197,9 @@ Check_Virtualization() {
|
||||
fi
|
||||
elif [ -f "/sys/hypervisor/type" ] && grep -q "xen" "/sys/hypervisor/type"; then
|
||||
virt="Xen"
|
||||
elif [[ "${sys_manu}" == *"Microsoft Corporation"* ]]; then
|
||||
if [[ "${sys_product}" == *"Virtual Machine"* ]]; then
|
||||
if [[ "${sys_ver}" == *"7.0"* || "${sys_ver}" == *"Hyper-V" ]]; then
|
||||
elif [[ ${sys_manu} == *"Microsoft Corporation"* ]]; then
|
||||
if [[ ${sys_product} == *"Virtual Machine"* ]]; then
|
||||
if [[ ${sys_ver} == *"7.0"* || ${sys_ver} == *"Hyper-V" ]]; then
|
||||
virt="Hyper-V"
|
||||
else
|
||||
virt="Microsoft Virtual Machine"
|
||||
@@ -167,12 +209,21 @@ Check_Virtualization() {
|
||||
virt="Dedicated"
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# city
|
||||
# country
|
||||
# org
|
||||
# public_ipv4
|
||||
# region
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
GetIpv4Info() {
|
||||
|
||||
|
||||
log "start to get system public ip info !"
|
||||
|
||||
org="$(wget -q -T10 -O- ipinfo.io/org)"
|
||||
@@ -181,10 +232,8 @@ GetIpv4Info() {
|
||||
region="$(wget -q -T10 -O- ipinfo.io/region)"
|
||||
public_ipv4="$(wget -q -T10 -O- ipinfo.io/ip)"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
log "start to collect system info !"
|
||||
|
||||
check_sys
|
||||
@@ -247,7 +296,6 @@ disk_used_size=$(
|
||||
disk_used_size=$(calc_size $disk_used_size)
|
||||
tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
|
||||
|
||||
|
||||
# todo
|
||||
# StartIOTest
|
||||
|
||||
@@ -262,7 +310,7 @@ if [[ $(cat /etc/hostname | cut -d"-" -f 3 | grep -c '^[0-9][0-9]') -gt 0 ]]; th
|
||||
else
|
||||
machineNumber=99
|
||||
fi
|
||||
cat >/etc/environment.d/octopus-agent.conf<<EOF
|
||||
cat >/etc/environment.d/octopus-agent.conf <<EOF
|
||||
serverName=${city}-${hostArch}-${machineNumber}
|
||||
serverIpPbV4=$public_ipv4
|
||||
serverIpInV4=
|
||||
@@ -289,4 +337,3 @@ log "env collect complete!"
|
||||
source /etc/environment
|
||||
|
||||
env
|
||||
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||
|
||||
OctopusAgentUrl=https://happybirthday.107421.xyz/octopus-agent/
|
||||
|
||||
|
||||
CheckAndDownloadLatestVersion(){
|
||||
CheckAndDownloadLatestVersion() {
|
||||
|
||||
log "checking for the latest version"
|
||||
local latestVersion=$(curl $OctopusAgentUrl | grep -v h1 | grep "a href=" | awk '{print$2}' |cut -d">" -f2 | cut -d"<" -f1)
|
||||
local latestVersion=$(curl $OctopusAgentUrl | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1)
|
||||
|
||||
log ""
|
||||
log "octopus agent latest version is => [ $latestVersion ]"
|
||||
echo ""
|
||||
log ""
|
||||
rm -rf /octopus-agent/*.jar
|
||||
cd /octopus-agent
|
||||
|
||||
log "start to download the latest version !"
|
||||
wget "$OctopusAgentUrl$latestVersion"
|
||||
cp "$latestVersion" agent.jar
|
||||
echo ""
|
||||
echo ""
|
||||
log "----------------------------------------------"
|
||||
log ""
|
||||
log ""
|
||||
log "---------------- ls the /octopus-agent ----------------------"
|
||||
ls /octopus-agent/ | grep jar
|
||||
log "----------------------------------------------"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user