[video] 新增video线管的内容

This commit is contained in:
zeaslity
2023-12-20 11:34:58 +08:00
parent 57b95e3610
commit 152aa80fe6
10 changed files with 402 additions and 14 deletions

View File

@@ -6,11 +6,12 @@
docker_version=20.10.10
oss_url_prefix="https://oss-s1.107421.xyz"
oss_url_prefix="http://10.250.0.100:9000/octopus"
modify_ssh_port=22333
octopus_agent_path=/usr/local/etc/octpus-agent
octopus_agent_url=https://happybirthday.107421.xyz/octopus-agent
agent_config_url=https://happybirthday.107421.xyz/agent-config
offline_host_ip="10.250.0.100"
# 脚本执行内容
deploy_in_cn=0
@@ -26,6 +27,7 @@ is_modify_ssh_port=0
is_install_agent=0
is_update_agent=0
is_remove_agent=0
is_offline=0
# 脚本执行内容
# read config
@@ -73,6 +75,9 @@ while [[ $# -gt 0 ]]; do
is_modify_ssh_port=1
modify_ssh_port=$2
;;
--offline)
is_offline=1
;;
--agent-install)
is_install_agent=1
;;
@@ -93,9 +98,11 @@ echo ""
echo ""
mkdir -p ${octopus_agent_path}/lib/
lib_file_list=(wdd-lib-log.sh wdd-lib-sys.sh)
# shellcheck disable=SC2068
for lib_file in ${lib_file_list[@]}; do
wget "${oss_url_prefix}/${lib_file}" -qO "${octopus_agent_path}/lib/${lib_file}"
echo "加载库文件 < ${octopus_agent_path}/lib/${lib_file}"
# shellcheck disable=SC1090
. "${octopus_agent_path}/lib/${lib_file}"
done
@@ -111,6 +118,7 @@ done
## 安装所需要的程序,及依赖程序
install_demand_softwares() {
local software=""
# shellcheck disable=SC2068
for software in $@; do
## 安装该软件
if [[ -n $(command -v "${software}") ]]; then
@@ -273,6 +281,7 @@ install_docker() {
systemctl disable docker
local pre_soft_ware=(docker-ce containerd.io docker-ce-cli docker-compose kubelet kubeadm kubectl)
local pre_one=""
# shellcheck disable=SC2068
for pre_one in ${pre_soft_ware[@]}; do
$cmd_remove "$pre_one"
done
@@ -694,6 +703,7 @@ modify_ssh_port() {
local sshd_change_to_no=("ChallengeResponseAuthentication" "PermitEmptyPasswords" "StrictModes")
local yes_item
# shellcheck disable=SC2068
for yes_item in ${sshd_change_to_yes[@]}; do
if grep -x "$yes_item yes" $ssh_config_file; then
# 已经存在了,什么都不做
@@ -711,6 +721,7 @@ modify_ssh_port() {
done
local no_item
# shellcheck disable=SC2068
for no_item in ${sshd_change_to_no[@]}; do
if grep -x "$no_item no" $ssh_config_file; then
:
@@ -786,7 +797,7 @@ modify_ssh_login() {
SplitLine
log "下载公共id_rsa.pub文件"
wget https://oss-s1.107421.xyz/ssh_key_pub.txt -qO /tmp/ssh_key_pub.txt
wget "$oss_url_prefix/ssh_key_pub.txt" -qO /tmp/ssh_key_pub.txt
if [[ ! -s /tmp/ssh_key_pub.txt ]]; then
error "下载 ssh-key 失败!"
return 1
@@ -814,9 +825,11 @@ common_tool_install() {
echo ""
if [[ ${linux_release_version} == "centos" ]]; then
local centos_common_tool=(deltarpm net-tools iputils bind-utils lsof curl wget vim mtr htop)
# shellcheck disable=SC2068
install_demand_softwares ${centos_common_tool[@]}
elif [[ ${linux_release_version} == "ubuntu" ]] || [[ ${linux_release_version} == "debian" ]]; then
local ubuntu_common_tool=(iputils-ping net-tools dnsutils lsof curl wget mtr-tiny vim htop lrzsz)
# shellcheck disable=SC2068
install_demand_softwares ${ubuntu_common_tool[@]}
fi
FunctionEnd
@@ -839,6 +852,7 @@ remove_octopus_agent() {
local systemd_config_file
local agent_installed=0
# shellcheck disable=SC2068
for systemd_config_file in ${systemd_config_path[@]}; do
if ls "${systemd_config_file}"* | grep -q octopus-agent.service; then
agent_installed=1
@@ -892,7 +906,7 @@ SyslogIdentifier=octopus-agent
User=root
Type=simple
WorkingDirectory=$octopus_agent_path
ExecStart=$octopus_agent_path/octopus-agent -agentServerInfoConf=$octopus_agent_path/octopus-agent.conf -version=shanghai
ExecStart=$octopus_agent_path/octopus-agent -agentServerInfoConf=$octopus_agent_path/octopus-agent.conf -version=standard
ExecStop=/bin/kill -15 \$MAINPID
[Install]
@@ -928,11 +942,30 @@ install_octopus_agent() {
FunctionStart "安装 Octopus Agent"
colorEchoBlue "开始检查最新的版本!"
local latest_version=$(curl "$octopus_agent_url/" | grep -v h1 | grep "a href=" | head -1 | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4-)
# add for offline version
if [[ $is_offline -eq 1 ]]; then
octopus_agent_url="http://${offline_host_ip}/octopus-agent"
agent_config_url="http://${offline_host_ip}/agent-config"
colorEchoBlue "[install_octopus_agent] - offline agent url are => $octopus_agent_url"
fi
local latest_version=""
latest_version=$(curl "$octopus_agent_url/" | grep -v h1 | grep "a href=" | head -1 | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4-)
if [[ $latest_version == "" ]]; then
echo ""
colorEchoRed "[install_octopus_agent] - get agent version error ! break !"
colorEchoRed "[install_octopus_agent] - get agent version error ! break !"
echo ""
return 233
fi
log "查询得到的Octopus Agent的最新版本为 => ${latest_version}"
SplitBlue
# Agent二进制文件的命名规则为 octopus-agent_linux_amd64_<version>
# shellcheck disable=SC2154
local agent_latest_version="octopus-agent_linux_${linux_release}_${latest_version}"
colorEchoBlue "octopus agent latest version is => [ $agent_latest_version ]"
@@ -949,7 +982,8 @@ install_octopus_agent() {
log "开始下载 Octopus Agent Config !"
rm -rf index.html
local agentConfigFileList=$(curl "$agent_config_url/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4- | tr "\n" " ")
local agentConfigFileList=""
agentConfigFileList=$(curl "$agent_config_url/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4- | tr "\n" " ")
IFS=" " read -ra file_array <<<"$agentConfigFileList"
@@ -958,7 +992,7 @@ install_octopus_agent() {
colorEchoBlue "agent config file is => $agent_config"
wget -q "$agent_config_url/$agent_config" -qO "${octopus_agent_path}/$agent_config"
echo ""
done
done
colorEchoBlue "---------------- ls the ${octopus_agent_path} ----------------------"
ls ${octopus_agent_path} | grep ".yaml"
@@ -975,7 +1009,15 @@ install_octopus_agent() {
echo ""
SplitGreen
# ok
daemon_octopus_agent
echo ""
# change for it
sed -i "s/OFFLINE_HOST_IP/${offline_host_ip}/g" ${octopus_agent_path}/octopus-agent-standard.yaml
colorEchoGreen "[install_octopus_agent] - agent-config is ok !"
# see the config file
log "开始启动 Octopus Agent!"
@@ -1007,6 +1049,7 @@ update_octopus_agent(){
local systemd_config_file
local agent_installed=0
# shellcheck disable=SC2068
for systemd_config_file in ${systemd_config_path[@]}; do
if ls "${systemd_config_file}"* | grep -q octopus-agent.service; then
agent_installed=1
@@ -1029,9 +1072,26 @@ EOF
fi
colorEchoBlue "开始检查最新的版本!"
local latest_version=$(curl "$octopus_agent_url/" | grep -v h1 | grep "a href=" | head -1 | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4-)
# add for ofline version
if [[ $is_offline -eq 1 ]]; then
octopus_agent_url="http://$offline_host_ip/octopus-agent"
agent_config_url="http://$offline_host_ip/agent-config"
colorEchoBlue "[install_octopus_agent] - offline agent url are => $octopus_agent_url"
fi
local latest_version=""
latest_version=$(curl "$octopus_agent_url/" | grep -v h1 | grep "a href=" | head -1 | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4-)
log "查询得到的Octopus Agent的最新版本为 => ${latest_version}"
if [[ $latest_version == "" ]]; then
echo ""
colorEchoRed "[update_octopus_agent] - get agent version error ! break !"
colorEchoRed "[update_octopus_agent] - get agent version error ! break !"
echo ""
return 233
fi
SplitBlue
# Agent二进制文件的命名规则为 octopus-agent_linux_amd64_<version>
local agent_latest_version="octopus-agent_linux_${linux_release}_${latest_version}"
@@ -1050,7 +1110,8 @@ EOF
log "开始下载 Octopus Agent Config !"
rm -rf index.html
local agentConfigFileList=$(curl "$agent_config_url/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4- | tr "\n" " ")
local agentConfigFileList=""
agentConfigFileList=$(curl "$agent_config_url/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4- | tr "\n" " ")
IFS=" " read -ra file_array <<<"$agentConfigFileList"
@@ -1066,6 +1127,9 @@ EOF
echo ""
log "开始重启启动 Octopus Agent!"
# change for it
sed -i "s/OFFLINE_HOST_IP/${offline_host_ip}/g" ${octopus_agent_path}/octopus-agent-standard.yaml
colorEchoGreen "[update_octopus_agent] - agent-config is ok !"
systemctl enable octopus-agent.service
systemctl start octopus-agent.service
@@ -1086,6 +1150,28 @@ EOF
FunctionEnd
}
build_offline_host_ip(){
FunctionStart "offline installation ! start to build for host ip !"
local host_ip=""
colorEchoBlue "[build_offline_host_ip] - offline install of octopus agent, oss url is => ${oss_url_prefix}"
host_ip=$(echo "$oss_url_prefix" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
echo ""
colorEchoBlue "[build_offline_host_ip] - make sure agent offline package has been synchronized to => $host_ip !"
colorEchoBlue "[build_offline_host_ip] - make sure agent offline package has been synchronized to => $host_ip !"
echo ""
if [[ "$host_ip" -eq "" ]]; then
colorEchoRed "[build_offline_host_ip] - offline host ip extraction error ! break !"
return 233
fi
offline_host_ip=${host_ip}
FunctionEnd
}
#######################################
# description
# Arguments:
@@ -1125,6 +1211,7 @@ help() {
--docker-compose 安装docker-compose 2.18.0
--zsh 安装并且配置ZSH
--cn 是否在国内安装
--offline 是否是纯离线安装
--host 是否配置服务器的Host解析
--time 是否配置时间同步
--ssh-login 修改ssh的登录密钥
@@ -1158,6 +1245,10 @@ main() {
check_root
check_sys
if [[ $is_offline -eq "1" ]]; then
build_offline_host_ip
fi
if [[ $is_shutdown_firewall -eq "1" ]]; then
shutdown_firewall
fi

View File

@@ -330,6 +330,18 @@ get_ipv4_info() {
public_ipv4="$(wget -q -T10 -O- ipinfo.io/ip)"
public_ipv6="$(curl -q --max-time 5 -6 https://ifconfig.co/ip)"
if [[ $city -eq "" ]]; then
city="Chengdu"
fi
if [[ $country -eq "" ]]; then
country="CN"
fi
if [[ $region -eq "" ]]; then
region="Shuangliu"
fi
if [ -z "$public_ipv4" ]; then
public_ipv4=" "
fi
@@ -458,7 +470,7 @@ collect_system_info() {
uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
)
fi
os_info=$(get_host_arch_info)
os_info=$(get_host_arch_info | tr "\n" " ")
arch=$(uname -m)
local l_bit
if command_exists "getconf"; then

View File

@@ -1,14 +1,14 @@
#!/bin/bash
oss_url_prefix="https://oss-s1.107421.xyz"
octopus_agent_path=/usr/local/etc/octpus-agent
echo ""
echo ""
lib_file_list=(wdd-lib-log.sh)
# shellcheck disable=SC2068
for lib_file in ${lib_file_list[@]}; do
# shellcheck disable=SC2154
wget "${oss_url_prefix}/${lib_file}" -qO "${octopus_agent_path}/lib/${lib_file}"
echo "加载库文件 < ${octopus_agent_path}/lib/${lib_file}"
# shellcheck disable=SC1090
. "${octopus_agent_path}/lib/${lib_file}"
done
@@ -112,6 +112,7 @@ check_sys() {
elif [[ -n $(command -v zypper) ]]; then
cmd_install="zypper -y install"
cmd_update="zypper ref"
# shellcheck disable=SC2034
cmd_remove="zypper -y remove"
else
return 1
@@ -128,6 +129,13 @@ check_sys() {
log "系统包管理工具为 => $cmd_install"
# shellcheck disable=SC2154
if [[ $is_offline == 1 ]]; then
FunctionEnd
return 0
fi
### 更新程序引索
if [[ $software_updated -eq 0 ]]; then
log "正在更新软件包管理...可能花费较长时间…………"

View File

@@ -0,0 +1,118 @@
#!/bin/bash
# set -o errexit
# set -o nounset
# set -o pipefail
octopus_agent_url=https://happybirthday.107421.xyz/octopus-agent
agent_config_url=https://happybirthday.107421.xyz/agent-config
default_octopus_agent_local_path=/data/github-action/octopus-agent/
default_octopus_agent_config_local_path=/data/github-action/agent-config/
sync_octopus_agent(){
local octopus_agent_html="octopus_agent.html"
rm -rf ${octopus_agent_html}
wget "$octopus_agent_url/" -qO ${octopus_agent_html}
if [[ ! -s $octopus_agent_html ]]; then
echo "[sync_octopus_agent] - download agent version file error ! return false !"
return 233
fi
echo "清除旧的Agnet内容"
rm -rf ${default_octopus_agent_local_path}
mkdir -p ${default_octopus_agent_local_path}
echo ""
echo "开始同步最新版本的Octopus Agent !"
local octopus_agent_config_file_list=""
# shellcheck disable=SC2034
octopus_agent_config_file_list=$(cat ${octopus_agent_html} | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | tr "\n" " ")
local octopus_agent_config_list
IFS=" " read -ra octopus_agent_config_list <<<"$octopus_agent_config_file_list"
echo ""
local octopus_agent_file
for octopus_agent_file in "${octopus_agent_config_list[@]}"
do
echo "[sync_octopus_agent] => start to download => ${octopus_agent_url}/${octopus_agent_file}"
wget "${octopus_agent_url}/${octopus_agent_file}" -qO "${default_octopus_agent_local_path}${octopus_agent_file}"
echo ""
if [[ ! -s "${default_octopus_agent_local_path}${octopus_agent_file}" ]]; then
echo ""
echo "[sync_octopus_agent] - ERROR download file ${octopus_agent_url}/${octopus_agent_file} !"
echo ""
return 233
fi
done
echo "[sync_octopus_agent] - check for octopus agent download .."
echo ""
ls ${default_octopus_agent_local_path}
echo ""
echo ""
}
sync_octopus_agent_config(){
local octopus_agent_config_html="octopus_agent_config.html"
rm -rf ${octopus_agent_config_html}
wget "$agent_config_url/" -qO ${octopus_agent_config_html}
if [[ ! -s $octopus_agent_config_html ]]; then
echo "[sync_octopus_agent_config] - download agent config file error ! return false !"
return 233
fi
echo "清除旧的Agnet Config内容"
rm -rf $default_octopus_agent_config_local_path
mkdir -p ${default_octopus_agent_config_local_path}
echo ""
echo "开始同步最新版本的Octopus Agent Config !"
local octopus_agent_config_file_list=""
# shellcheck disable=SC2034
octopus_agent_config_file_list=$(cat ${octopus_agent_config_html} | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | tr "\n" " ")
local octopus_agent_config_list
IFS=" " read -ra octopus_agent_config_list <<<"$octopus_agent_config_file_list"
echo ""
local octopus_agent_config_file
for octopus_agent_config_file in "${octopus_agent_config_list[@]}"
do
echo "[sync_octopus_agent_config] => start to download => ${agent_config_url}/${octopus_agent_config_file}"
wget "${agent_config_url}/${octopus_agent_config_file}" -qO "${default_octopus_agent_config_local_path}${octopus_agent_config_file}"
echo ""
if [[ ! -s "${default_octopus_agent_config_local_path}${octopus_agent_config_file}" ]]; then
echo ""
echo "[sync_octopus_agent_config] - ERROR download file ${agent_config_url}/${octopus_agent_config_file} !"
echo ""
return 233
fi
done
echo "[sync_octopus_agent_config] - check for octopus agent config download .."
echo ""
ls ${default_octopus_agent_config_local_path}
echo ""
echo ""
}
main(){
sync_octopus_agent
sync_octopus_agent_config
}
main