大量更新
This commit is contained in:
35
3-wdd初始化-OSS/dep/octopus-offline-nginx.conf
Normal file
35
3-wdd初始化-OSS/dep/octopus-offline-nginx.conf
Normal file
@@ -0,0 +1,35 @@
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
location /octopus-agent/ {
|
||||
|
||||
root /data/github-action;
|
||||
|
||||
autoindex on; # 开启目录浏览功能;
|
||||
}
|
||||
|
||||
|
||||
location /shell/ {
|
||||
|
||||
root /data/github-action;
|
||||
|
||||
autoindex on; # 开启目录浏览功能;
|
||||
|
||||
}
|
||||
|
||||
location /agent-config/ {
|
||||
|
||||
root /data/github-action;
|
||||
|
||||
autoindex on; # 开启目录浏览功能;
|
||||
|
||||
}
|
||||
|
||||
location /agent-version {
|
||||
add_header Content-Type text/plain;
|
||||
alias /data/github-action/agent-version;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
25
3-wdd初始化-OSS/dep/octopus_ssh_banner
Normal file
25
3-wdd初始化-OSS/dep/octopus_ssh_banner
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
______ __ ______ __
|
||||
/ \ | \ / \ | \
|
||||
| $$$$$$\ _______ _| $$_ ______ ______ __ __ _______ | $$$$$$\ ______ ______ _______ _| $$_
|
||||
| $$ | $$/ | $$ \ / \ / \| \ | \/ \ | $$__| $$/ \ / \| | $$ \
|
||||
| $$ | $| $$$$$$$\$$$$$$ | $$$$$$| $$$$$$| $$ | $| $$$$$$$ | $$ $| $$$$$$| $$$$$$| $$$$$$$\$$$$$$
|
||||
| $$ | $| $$ | $$ __| $$ | $| $$ | $| $$ | $$\$$ \ | $$$$$$$| $$ | $| $$ $| $$ | $$| $$ __
|
||||
| $$__/ $| $$_____ | $$| | $$__/ $| $$__/ $| $$__/ $$_\$$$$$$\ | $$ | $| $$__| $| $$$$$$$| $$ | $$| $$| \
|
||||
\$$ $$\$$ \ \$$ $$\$$ $| $$ $$\$$ $| $$ | $$ | $$\$$ $$\$$ | $$ | $$ \$$ $$
|
||||
\$$$$$$ \$$$$$$$ \$$$$ \$$$$$$| $$$$$$$ \$$$$$$ \$$$$$$$ \$$ \$$_\$$$$$$$ \$$$$$$$\$$ \$$ \$$$$
|
||||
| $$ | \__| $$
|
||||
| $$ \$$ $$
|
||||
\$$ \$$$$$$
|
||||
__ __
|
||||
| \ | \
|
||||
____| $$ ______ ____| $$ ______ __ __ __ ______ _______ ______
|
||||
______ ______ ______ / $$| \ / $$| \ | \ | \ | \| \| \ / \
|
||||
| | | \ | $$$$$$$ \$$$$$$| $$$$$$$ \$$$$$$\ | $$ | $$ | $$ \$$$$$$| $$$$$$$| $$$$$$\
|
||||
\$$$$$$\$$$$$$\$$$$$$ | $$ | $$/ $| $$ | $$/ $$ | $$ | $$ | $$/ $| $$ | $| $$ | $$
|
||||
| $$__| $| $$$$$$| $$__| $| $$$$$$$ | $$_/ $$_/ $| $$$$$$| $$ | $| $$__| $$
|
||||
\$$ $$\$$ $$\$$ $$\$$ $$ \$$ $$ $$\$$ $| $$ | $$\$$ $$
|
||||
\$$$$$$$ \$$$$$$$ \$$$$$$$ \$$$$$$$ \$$$$$\$$$$ \$$$$$$$\$$ \$$_\$$$$$$$
|
||||
| \__| $$
|
||||
\$$ $$
|
||||
\$$$$$$
|
||||
3
3-wdd初始化-OSS/dep/oh-my-zsh-plugins-list.txt
Normal file
3
3-wdd初始化-OSS/dep/oh-my-zsh-plugins-list.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/plugins/command-not-found/command-not-found.plugin.zsh
|
||||
https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/plugins/autojump/autojump.plugin.zsh
|
||||
https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/plugins/themes/themes.plugin.zsh
|
||||
2
3-wdd初始化-OSS/dep/ssh_key_pub.txt
Normal file
2
3-wdd初始化-OSS/dep/ssh_key_pub.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDL9S6CSAjTFe2fy4bAIfqu90ft6E+GBRvS59kno6LDeAbqUQNYf9hEnIg07Ee/x5DlnYE0S3Ykv3WCHuVyBH2zANnC0P87SqphDGmoqdqF3r6uDaCr4lBsUqEai9X2q6dyjZj6ym+r4zQhMApNDzbhcyfKQ54tKFylGIdx6siyktuU/VbOzWc6G8r+BfFsQpMCA1ihmCY1jGjsKPqFlZGLeTrlBb1Zk0OV+GtDhlf/t0cd0kRPJoydm2juTXrZO+tFmf9turfKZsBnRYKtQBLJG5mF1hsjIqo8DHr+PUL2wRrSxEhGTZiJL4rNJo/kHhKXXsomc5RM/AnfgAfxrLlH zeasl@DESKTOP-K2F9GG3
|
||||
49
3-wdd初始化-OSS/dep/wdd-server-host.txt
Normal file
49
3-wdd初始化-OSS/dep/wdd-server-host.txt
Normal file
@@ -0,0 +1,49 @@
|
||||
132.145.87.10 arm-s-1 s0
|
||||
10.0.0.91 arm-s-1 s0
|
||||
|
||||
146.56.159.175 arm-s-2 s5
|
||||
10.0.0.173 arm-s-2 s5
|
||||
|
||||
140.238.8.73 seoul-1 s1
|
||||
10.0.0.3 seoul-1 s1
|
||||
|
||||
140.238.30.110 seoul-2 s2
|
||||
10.0.0.14 seoul-2 s2
|
||||
|
||||
140.238.29.102 seoul-3 s3
|
||||
10.0.0.2 seoul-3 s3
|
||||
|
||||
140.238.14.103 seoul-4 s4
|
||||
10.0.0.3 seoul-4 s4
|
||||
|
||||
150.230.198.103 tokyo-0 t0
|
||||
|
||||
140.238.63.37 tokyo-1 t1
|
||||
|
||||
140.238.52.228 tokyo-2 t2
|
||||
|
||||
140.83.84.142 osaka-1 o1
|
||||
|
||||
140.83.58.96 osaka-2 o2
|
||||
|
||||
129.146.171.163 p2
|
||||
|
||||
129.146.65.80 p3
|
||||
|
||||
129.146.57.94 p4
|
||||
|
||||
42.192.52.227 tc-sh
|
||||
|
||||
43.128.39.232 tc-hk
|
||||
|
||||
114.117.165.222 tc-cd
|
||||
|
||||
89.208.251.209 los-1
|
||||
|
||||
45.134.50.233 de-1
|
||||
|
||||
158.180.57.125 frankfurt-1 f1
|
||||
|
||||
158.180.27.191 frankfurt-2 f2
|
||||
|
||||
|
||||
1375
3-wdd初始化-OSS/init-script-wdd.sh
Normal file
1375
3-wdd初始化-OSS/init-script-wdd.sh
Normal file
File diff suppressed because it is too large
Load Diff
46
3-wdd初始化-OSS/lib/wdd-lib-clean.sh
Normal file
46
3-wdd初始化-OSS/lib/wdd-lib-clean.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f /root/wdd/lib/wdd-lib-log.sh ]]; then
|
||||
wget https://oss-s1.107421.xyz/wdd-lib-log.sh -O /root/wdd/lib/wdd-lib-log.sh
|
||||
fi
|
||||
source /root/wdd/lib/wdd-lib-log.sh
|
||||
|
||||
clean_oracle_agent() {
|
||||
|
||||
FunctionStart
|
||||
colorEchoBlue "准备清理 Oracle Agent的相关内容 !"
|
||||
snap info oracle-cloud-agent
|
||||
snap stop oracle-cloud-agent
|
||||
snap remove oracle-cloud-agent
|
||||
|
||||
|
||||
for i in $(ls /lib/systemd/system/ | grep snapd | awk '{print$1}'); do
|
||||
echo $i
|
||||
systemctl stop $i
|
||||
systemctl disable $i
|
||||
done
|
||||
|
||||
local loop
|
||||
for loop in $(df -h | grep snap | awk '{print$1}');do
|
||||
echo "unmount $loop"
|
||||
umount "$loop"
|
||||
done
|
||||
|
||||
rm -rf /root/snap
|
||||
rm -rf /var/snap
|
||||
rm -rf /usr/bin/snap
|
||||
rm -rf /snap/
|
||||
rm -rf /var/lib/snapd
|
||||
|
||||
FunctionSuccess
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
clean_ip_persist() {
|
||||
FunctionStart
|
||||
colorEchoBlue "开始关闭 防火墙持久化存储 …………"
|
||||
systemctl stop systemd-resolved.service && systemctl disable systemd-resolved.service
|
||||
systemctl stop netfilter-persistent.service && systemctl disable netfilter-persistent.service
|
||||
FunctionEnd
|
||||
FunctionSuccess
|
||||
}
|
||||
625
3-wdd初始化-OSS/lib/wdd-lib-env.sh
Normal file
625
3-wdd初始化-OSS/lib/wdd-lib-env.sh
Normal file
@@ -0,0 +1,625 @@
|
||||
#!/bin/bash
|
||||
|
||||
octopus_agent_path=/usr/local/etc/octpus-agent
|
||||
. "$octopus_agent_path/lib/wdd-lib-log.sh"
|
||||
. "$octopus_agent_path/lib/wdd-lib-sys.sh"
|
||||
|
||||
host_arch_version=""
|
||||
cpu_arch=""
|
||||
#### CollectSystemInfo ####
|
||||
server_name=""
|
||||
server_ip_pb_v4=""
|
||||
server_ip_in_v4=""
|
||||
server_ip_pb_v6=""
|
||||
server_ip_in_v6=""
|
||||
location=""
|
||||
provider=""
|
||||
manage_port=""
|
||||
cpu_brand=""
|
||||
cpu_core=""
|
||||
memory_total=""
|
||||
disk_total=""
|
||||
disk_usage=""
|
||||
os_info=""
|
||||
os_kernel_info=""
|
||||
tcp_control=""
|
||||
virtualization=""
|
||||
io_speed=""
|
||||
machine_id=""
|
||||
arch_info=""
|
||||
agent_version=""
|
||||
os_bit=""
|
||||
|
||||
### tmp usage
|
||||
io_speed=""
|
||||
public_ipv4=""
|
||||
inner_ipv4=""
|
||||
public_ipv6=""
|
||||
inner_ipv6=""
|
||||
country=""
|
||||
region=""
|
||||
city=""
|
||||
net_provider=""
|
||||
manage_port=""
|
||||
machine_number=""
|
||||
l_bit=""
|
||||
#### CollectSystemInfo ####
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# 1
|
||||
#######################################
|
||||
io_test() {
|
||||
(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]*$//'
|
||||
}
|
||||
|
||||
####### 获取系统版本及64位或32位信息
|
||||
check_sys() {
|
||||
local sys_bit
|
||||
sys_bit=$(uname -m)
|
||||
case $sys_bit in
|
||||
i[36]86)
|
||||
os_bit="32"
|
||||
cpu_arch="386"
|
||||
;;
|
||||
x86_64)
|
||||
os_bit="64"
|
||||
cpu_arch="amd64"
|
||||
;;
|
||||
*armv6*)
|
||||
os_bit="arm"
|
||||
cpu_arch="arm6"
|
||||
;;
|
||||
*armv7*)
|
||||
os_bit="arm"
|
||||
cpu_arch="arm7"
|
||||
;;
|
||||
*aarch64* | *armv8*)
|
||||
os_bit="arm64"
|
||||
cpu_arch="arm64"
|
||||
;;
|
||||
*)
|
||||
error "
|
||||
哈哈……这个 辣鸡脚本 不支持你的系统。 (-_-) \n
|
||||
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
|
||||
" && exit 1
|
||||
;;
|
||||
esac
|
||||
## 判定Linux的发行版本
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
host_arch_version="centos"
|
||||
elif cat /etc/issue | grep -Eqi "debian"; then
|
||||
host_arch_version="debian"
|
||||
elif cat /etc/issue | grep -Eqi "ubuntu"; then
|
||||
host_arch_version="ubuntu"
|
||||
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
|
||||
host_arch_version="centos"
|
||||
elif cat /proc/version | grep -Eqi "debian"; then
|
||||
host_arch_version="debian"
|
||||
elif cat /proc/version | grep -Eqi "ubuntu"; then
|
||||
host_arch_version="ubuntu"
|
||||
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
|
||||
host_arch_version="centos"
|
||||
else
|
||||
host_arch_version=""
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# 1
|
||||
# Returns:
|
||||
# <unknown> ...
|
||||
#######################################
|
||||
calc_size() {
|
||||
local raw=$1
|
||||
local total_size=0
|
||||
local num=1
|
||||
local unit="KB"
|
||||
if ! [[ ${raw} =~ ^[0-9]+$ ]]; then
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
if [ "${raw}" -ge 1073741824 ]; then
|
||||
num=1073741824
|
||||
unit="TB"
|
||||
elif [ "${raw}" -ge 1048576 ]; then
|
||||
num=1048576
|
||||
unit="GB"
|
||||
elif [ "${raw}" -ge 1024 ]; then
|
||||
num=1024
|
||||
unit="MB"
|
||||
elif [ "${raw}" -eq 0 ]; then
|
||||
echo "${total_size}"
|
||||
return
|
||||
fi
|
||||
total_size=$(awk 'BEGIN{printf "%.1f", '$raw' / '$num'}')
|
||||
echo "${total_size} ${unit}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# <unknown> ...
|
||||
#######################################
|
||||
get_host_arch_info() {
|
||||
FunctionStart "开始获取系统架构信息!"
|
||||
|
||||
[ -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
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# freespace
|
||||
# io1
|
||||
# io2
|
||||
# io3
|
||||
# ioall
|
||||
# ioavg
|
||||
# ioraw1
|
||||
# ioraw2
|
||||
# ioraw3
|
||||
# writemb
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
start_io_test() {
|
||||
FunctionStart "开始测试IO速度!"
|
||||
freespace=$(df -m . | awk 'NR==2 {print $4}')
|
||||
if [ -z "${freespace}" ]; then
|
||||
freespace=$(df -m . | awk 'NR==3 {print $3}')
|
||||
fi
|
||||
if [ ${freespace} -gt 1024 ]; then
|
||||
writemb=2048
|
||||
io1=$(go_iotest ${writemb})
|
||||
log "I/O Speed(1st run) : $io1)"
|
||||
io2=$(go_iotest ${writemb})
|
||||
log "I/O Speed(2st run) : $io2)"
|
||||
io3=$(go_iotest ${writemb})
|
||||
log "I/O Speed(3st run) : $io3)"
|
||||
ioraw1=$(echo $io1 | awk 'NR==1 {print $1}')
|
||||
[ "$(echo $io1 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$(awk 'BEGIN{print '$ioraw1' * 1024}')
|
||||
ioraw2=$(echo $io2 | awk 'NR==1 {print $1}')
|
||||
[ "$(echo $io2 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw2=$(awk 'BEGIN{print '$ioraw2' * 1024}')
|
||||
ioraw3=$(echo $io3 | awk 'NR==1 {print $1}')
|
||||
[ "$(echo $io3 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$(awk 'BEGIN{print '$ioraw3' * 1024}')
|
||||
ioall=$(awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}')
|
||||
io_speed=$(awk 'BEGIN{printf "%.1f", '$ioall' / 3}')
|
||||
log "I/O Speed(average) : $io_speed MB/s)"
|
||||
else
|
||||
echo " $(_red "Not enough space for I/O Speed test!")"
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# cpu_name
|
||||
# sys_manu
|
||||
# sys_product
|
||||
# sys_ver
|
||||
# virt
|
||||
# virtual_x
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
check_virtualization() {
|
||||
|
||||
FunctionStart "开始收集服务器虚拟化信息!"
|
||||
|
||||
local virtual_x
|
||||
if command_exists "dmesg"; then
|
||||
virtual_x="$(dmesg 2>/dev/null)"
|
||||
fi
|
||||
|
||||
local sys_manu
|
||||
local sys_product
|
||||
local sys_ver
|
||||
|
||||
if command_exists "dmidecode"; then
|
||||
sys_manu="$(dmidecode -s system-manufacturer 2>/dev/null)"
|
||||
sys_product="$(dmidecode -s system-product-name 2>/dev/null)"
|
||||
sys_ver="$(dmidecode -s system-version 2>/dev/null)"
|
||||
else
|
||||
sys_manu=""
|
||||
sys_product=""
|
||||
sys_ver=""
|
||||
fi
|
||||
if grep -qa docker /proc/1/cgroup; then
|
||||
virt="Docker"
|
||||
elif grep -qa lxc /proc/1/cgroup; then
|
||||
virt="LXC"
|
||||
elif grep -qa container=lxc /proc/1/environ; then
|
||||
virt="LXC"
|
||||
elif [[ -f /proc/user_beancounters ]]; then
|
||||
virt="OpenVZ"
|
||||
elif [[ ${virtual_x} == *kvm-clock* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${sys_product} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${cpu_name} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${cpu_name} == *QEMU* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${virtual_x} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ ${sys_product} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ ${virtual_x} == *"Parallels Software International"* ]]; then
|
||||
virt="Parallels"
|
||||
elif [[ ${virtual_x} == *VirtualBox* ]]; then
|
||||
virt="VirtualBox"
|
||||
elif [[ -e /proc/xen ]]; then
|
||||
if grep -q "control_d" "/proc/xen/capabilities" 2>/dev/null; then
|
||||
virt="Xen-Dom0"
|
||||
else
|
||||
virt="Xen-DomU"
|
||||
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
|
||||
virt="Hyper-V"
|
||||
else
|
||||
virt="Microsoft Virtual Machine"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
virt="Dedicated"
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# manage_port
|
||||
# tmp_manage_ports
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
get_manage_port() {
|
||||
|
||||
FunctionStart "开始收集服务器 管理端口 信息!"
|
||||
local tmp_manage_ports
|
||||
tmp_manage_ports=$(netstat -ntulp | grep sshd | grep -w tcp | grep -v "127.0.0.1" | awk '{print$4}' | cut -d":" -f2)
|
||||
|
||||
manage_port=$(echo "$tmp_manage_ports" | tr '\n' ' ')
|
||||
|
||||
log "manage Port is => $manage_port"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# city
|
||||
# country
|
||||
# net_provider
|
||||
# public_ipv4
|
||||
# region
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
get_ipv4_info() {
|
||||
|
||||
FunctionStart "开始收集服务器IP信息!"
|
||||
|
||||
# public ip info
|
||||
net_provider="$(wget -q --timeout=2 -O- ipinfo.io/org)"
|
||||
city="$(wget -q --timeout=2 -O- ipinfo.io/city)"
|
||||
country="$(wget -q --timeout=2 -O- ipinfo.io/country)"
|
||||
region="$(wget -q --timeout=2 -O- ipinfo.io/region)"
|
||||
public_ipv4="$(wget -q --timeout=2 -O- ipinfo.io/ip)"
|
||||
public_ipv6="$(curl -q --max-time 2 -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
|
||||
|
||||
if [ -z "$public_ipv6" ]; then
|
||||
public_ipv6=" "
|
||||
fi
|
||||
|
||||
# inner ipinfo
|
||||
local interface_prefix=("eth[0-9]{1,2}" "ens[0-9]{1,3}" "eno[0-9]{1,3}" "enp[0-9]{1,2}" "enp[0-9]{1,2}s[0-9]{1,2}")
|
||||
local real_interface="eth90"
|
||||
|
||||
local interface
|
||||
|
||||
if command_exists ifconfig; then
|
||||
log "使用ifconfig检测内部IP地址信息!"
|
||||
for interface in "${interface_prefix[@]}"; do
|
||||
if ifconfig | grep -oqE "${interface}:"; then
|
||||
real_interface=$(ifconfig | grep -E "${interface}:" | cut -d ":" -f1)
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
log "使用 ip link show检测内部IP地址信息!"
|
||||
for interface in "${interface_prefix[@]}"; do
|
||||
if ip link show | grep -oqE "${interface}:"; then
|
||||
real_interface=$(ip link show | grep -oE "${interface}:" | head -1 | cut -d" " -f2)
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo "当前主机的真实内网网卡为 => [$real_interface]"
|
||||
|
||||
# 提取IPv4地址(CIDR格式)
|
||||
local ipv4_regex="inet[[:space:]](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[0-9]{1,2}"
|
||||
|
||||
# 提取IPv6地址(CIDR格式)
|
||||
local ipv6_regex="inet6[[:space:]]([0-9a-fA-F]{0,4}(:[0-9a-fA-F]{0,4}){1,7})\/[0-9]{1,3}"
|
||||
|
||||
# 查找IPv4地址
|
||||
inner_ipv4=$(ip addr show "$real_interface" | grep -oE "$ipv4_regex" | grep -v 127 | cut -d" " -f2)
|
||||
echo "Interface: $real_interface, IPv4 Address: $inner_ipv4"
|
||||
|
||||
# 查找IPv6地址
|
||||
inner_ipv6=$(ip addr show "$real_interface" | grep -oE "$ipv6_regex" | grep -v "::1" | cut -d" " -f2)
|
||||
echo "Interface: $real_interface, IPv4 Address: $inner_ipv6"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# LANG
|
||||
# arch
|
||||
# c_cache
|
||||
# cores
|
||||
# cpu_aes
|
||||
# cpu_name
|
||||
# cpu_virt
|
||||
# disk_total_size
|
||||
# disk_used_size
|
||||
# cpu_freq
|
||||
# kernel_info
|
||||
# lbit
|
||||
# load
|
||||
# os_info
|
||||
# swap
|
||||
# tcp_ctrl
|
||||
# mem_total
|
||||
# unused_ram
|
||||
# unused_swap
|
||||
# up
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
collect_system_info() {
|
||||
FunctionStart "开始收集系统信息!"
|
||||
|
||||
check_sys
|
||||
|
||||
cpu_name=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cores=$(awk -F: '/processor/ {core++} END {print core}' /proc/cpuinfo)
|
||||
cpu_freq=$(awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo)
|
||||
local c_cache
|
||||
local cpu_aes
|
||||
local cpu_virt
|
||||
c_cache=$(awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cpu_aes=$(grep -i 'aes' /proc/cpuinfo)
|
||||
cpu_virt=$(grep -Ei 'vmx|svm' /proc/cpuinfo)
|
||||
mem_total=$(
|
||||
LANG=C
|
||||
free | awk '/Mem/ {print $2}'
|
||||
)
|
||||
mem_total=$(calc_size "$mem_total")
|
||||
local unused_ram
|
||||
unused_ram=$(
|
||||
LANG=C
|
||||
free | awk '/Mem/ {print $3}'
|
||||
)
|
||||
unused_ram=$(calc_size "$unused_ram")
|
||||
local swap
|
||||
swap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $2}'
|
||||
)
|
||||
swap=$(calc_size "$swap")
|
||||
local unused_swap
|
||||
unused_swap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $3}'
|
||||
)
|
||||
unused_swap=$(calc_size "$unused_swap")
|
||||
local up
|
||||
up=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime)
|
||||
local load
|
||||
if command_exists "w"; then
|
||||
load=$(
|
||||
LANG=C
|
||||
w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
)
|
||||
elif command_exists "uptime"; then
|
||||
load=$(
|
||||
LANG=C
|
||||
uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
)
|
||||
fi
|
||||
os_info=$(get_host_arch_info | tr "\n" " ")
|
||||
arch=$(uname -m)
|
||||
local l_bit
|
||||
if command_exists "getconf"; then
|
||||
l_bit=$(getconf LONG_BIT)
|
||||
else
|
||||
echo "${arch}" | grep -q "64" && l_bit="64" || l_bit="32"
|
||||
fi
|
||||
kernel_info=$(uname -r)
|
||||
disk_total_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }'
|
||||
)
|
||||
disk_total_size=$(calc_size "$disk_total_size")
|
||||
disk_used_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $3 }'
|
||||
)
|
||||
disk_used_size=$(calc_size "$disk_used_size")
|
||||
tcp_ctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
|
||||
|
||||
if [[ $(cut -d"-" -f 3 </etc/hostname | grep -c '^[0-9][0-9]') -gt 0 ]]; then
|
||||
machine_number=$(cut -d"-" -f 3 </etc/hostname)
|
||||
else
|
||||
machine_number=99
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# agent_version
|
||||
# octopus_agent_path
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
get_agent_version() {
|
||||
FunctionStart "获取Agent的版本信息"
|
||||
|
||||
local file
|
||||
for file in "${octopus_agent_path}"/*; do
|
||||
if [[ ! -d ${file} ]]; then
|
||||
if echo "$file" | grep "octopus-agent_linux_amd64_"; then
|
||||
agent_version=$(echo "${file}" | cut -d "_" -f4-)
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $agent_version -eq "" ]]; then
|
||||
agent_version=2011-11-11-11-11-11
|
||||
fi
|
||||
|
||||
log "获取到的Agent版本信息为 => ${agent_version}"
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# agent_server_info_file
|
||||
# arch
|
||||
# city
|
||||
# cores
|
||||
# country
|
||||
# cpu_name
|
||||
# disk_total_size
|
||||
# disk_used_size
|
||||
# cpu_freq
|
||||
# cpu_arch
|
||||
# inner_ipv4
|
||||
# inner_ipv6
|
||||
# io_speed
|
||||
# kernel_info
|
||||
# lbit
|
||||
# machine_number
|
||||
# manage_port
|
||||
# os_info
|
||||
# net_provider
|
||||
# public_ipv4
|
||||
# public_ipv6
|
||||
# region
|
||||
# tcp_ctrl
|
||||
# mem_total
|
||||
# virt
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
main() {
|
||||
# todo
|
||||
# start_iotest
|
||||
|
||||
check_sys
|
||||
|
||||
get_manage_port
|
||||
|
||||
collect_system_info
|
||||
|
||||
get_ipv4_info
|
||||
|
||||
check_virtualization
|
||||
|
||||
get_agent_version
|
||||
|
||||
local agent_server_info_file="$octopus_agent_path/octopus-agent-back.conf"
|
||||
|
||||
touch "$agent_server_info_file"
|
||||
cat >"$agent_server_info_file" <<EOF
|
||||
serverName: "${city}-${cpu_arch}-${machine_number}"
|
||||
serverIpPbV4: "$public_ipv4"
|
||||
serverIpInV4: "$inner_ipv4"
|
||||
serverIpPbV6: "$public_ipv6"
|
||||
serverIpInV6: "$inner_ipv6"
|
||||
location: "$city $region $country"
|
||||
provider: "$net_provider"
|
||||
managePort: "$manage_port"
|
||||
cpuCore: "$cores @ $cpu_freq MHz"
|
||||
cpuBrand: "$cpu_name"
|
||||
memoryTotal: "$mem_total"
|
||||
diskTotal: "$disk_total_size"
|
||||
diskUsage: "$disk_used_size"
|
||||
archInfo: "$arch ($os_bit Bit)"
|
||||
osInfo: "$os_info"
|
||||
osKernelInfo: "$kernel_info"
|
||||
tcpControl: "$tcp_ctrl"
|
||||
virtualization: "$virt"
|
||||
ioSpeed: "$io_speed MB/s"
|
||||
machineId: "$(cat /etc/machine-id)"
|
||||
agentVersion: "${agent_version}"
|
||||
EOF
|
||||
|
||||
log "agent server info has collect complete!"
|
||||
log "file is => $agent_server_info_file"
|
||||
echo ""
|
||||
|
||||
SplitGreen "查看Agent的环境信息!"
|
||||
cat - 1>&2 <<EOF
|
||||
|
||||
cat $agent_server_info_file
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
main
|
||||
191
3-wdd初始化-OSS/lib/wdd-lib-file.sh
Normal file
191
3-wdd初始化-OSS/lib/wdd-lib-file.sh
Normal file
@@ -0,0 +1,191 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Library for file system actions
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
|
||||
# Load Generic Libraries
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||
|
||||
# Functions
|
||||
|
||||
########################
|
||||
# Ensure a file/directory is owned (user and group) but the given user
|
||||
# Arguments:
|
||||
# $1 - filepath
|
||||
# $2 - owner
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
owned_by() {
|
||||
local path="${1:?path is missing}"
|
||||
local owner="${2:?owner is missing}"
|
||||
local group="${3:-}"
|
||||
|
||||
if [[ -n $group ]]; then
|
||||
chown "$owner":"$group" "$path"
|
||||
else
|
||||
chown "$owner":"$owner" "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Ensure a directory exists and, optionally, is owned by the given user
|
||||
# Arguments:
|
||||
# $1 - directory
|
||||
# $2 - owner
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
ensure_dir_exists() {
|
||||
local dir="${1:?directory is missing}"
|
||||
local owner_user="${2:-}"
|
||||
local owner_group="${3:-}"
|
||||
|
||||
mkdir -p "${dir}"
|
||||
if [[ -n $owner_user ]]; then
|
||||
owned_by "$dir" "$owner_user" "$owner_group"
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Checks whether a directory is empty or not
|
||||
# arguments:
|
||||
# $1 - directory
|
||||
# returns:
|
||||
# boolean
|
||||
#########################
|
||||
is_dir_empty() {
|
||||
local -r path="${1:?missing directory}"
|
||||
# Calculate real path in order to avoid issues with symlinks
|
||||
local -r dir="$(realpath "$path")"
|
||||
if [[ ! -e "$dir" ]] || [[ -z "$(ls -A "$dir")" ]]; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Checks whether a mounted directory is empty or not
|
||||
# arguments:
|
||||
# $1 - directory
|
||||
# returns:
|
||||
# boolean
|
||||
#########################
|
||||
is_mounted_dir_empty() {
|
||||
local dir="${1:?missing directory}"
|
||||
|
||||
if is_dir_empty "$dir" || find "$dir" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" -exec false {} +; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Checks whether a file can be written to or not
|
||||
# arguments:
|
||||
# $1 - file
|
||||
# returns:
|
||||
# boolean
|
||||
#########################
|
||||
is_file_writable() {
|
||||
local file="${1:?missing file}"
|
||||
local dir
|
||||
dir="$(dirname "$file")"
|
||||
|
||||
if [[ (-f "$file" && -w "$file") || (! -f "$file" && -d "$dir" && -w "$dir") ]]; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Relativize a path
|
||||
# arguments:
|
||||
# $1 - path
|
||||
# $2 - base
|
||||
# returns:
|
||||
# None
|
||||
#########################
|
||||
relativize() {
|
||||
local -r path="${1:?missing path}"
|
||||
local -r base="${2:?missing base}"
|
||||
pushd "$base" >/dev/null || exit
|
||||
realpath -q --no-symlinks --relative-base="$base" "$path" | sed -e 's|^/$|.|' -e 's|^/||'
|
||||
popd >/dev/null || exit
|
||||
}
|
||||
|
||||
########################
|
||||
# Configure permisions and ownership recursively
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# $1 - paths (as a string).
|
||||
# Flags:
|
||||
# -f|--file-mode - mode for directories.
|
||||
# -d|--dir-mode - mode for files.
|
||||
# -u|--user - user
|
||||
# -g|--group - group
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
configure_permissions_ownership() {
|
||||
local -r paths="${1:?paths is missing}"
|
||||
local dir_mode=""
|
||||
local file_mode=""
|
||||
local user=""
|
||||
local group=""
|
||||
|
||||
# Validate arguments
|
||||
shift 1
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-f | --file-mode)
|
||||
shift
|
||||
file_mode="${1:?missing mode for files}"
|
||||
;;
|
||||
-d | --dir-mode)
|
||||
shift
|
||||
dir_mode="${1:?missing mode for directories}"
|
||||
;;
|
||||
-u | --user)
|
||||
shift
|
||||
user="${1:?missing user}"
|
||||
;;
|
||||
-g | --group)
|
||||
shift
|
||||
group="${1:?missing group}"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid command line flag $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
read -r -a filepaths <<<"$paths"
|
||||
for p in "${filepaths[@]}"; do
|
||||
if [[ -e "$p" ]]; then
|
||||
find -L "$p" -printf ""
|
||||
if [[ -n $dir_mode ]]; then
|
||||
find -L "$p" -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode"
|
||||
fi
|
||||
if [[ -n $file_mode ]]; then
|
||||
find -L "$p" -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode"
|
||||
fi
|
||||
if [[ -n $user ]] && [[ -n $group ]]; then
|
||||
find -L "$p" -print0 | xargs -r -0 chown "${user}:${group}"
|
||||
elif [[ -n $user ]] && [[ -z $group ]]; then
|
||||
find -L "$p" -print0 | xargs -r -0 chown "${user}"
|
||||
elif [[ -z $user ]] && [[ -n $group ]]; then
|
||||
find -L "$p" -print0 | xargs -r -0 chgrp "${group}"
|
||||
fi
|
||||
else
|
||||
stderr_print "$p does not exist"
|
||||
fi
|
||||
done
|
||||
}
|
||||
191
3-wdd初始化-OSS/lib/wdd-lib-log.sh
Normal file
191
3-wdd初始化-OSS/lib/wdd-lib-log.sh
Normal file
@@ -0,0 +1,191 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# 日志模块
|
||||
|
||||
# Constants
|
||||
RESET='\033[0m' ## 普通黑
|
||||
RED='\033[38;5;1m' ## 姨妈红
|
||||
GREEN='\033[38;5;2m' ## 水鸭青
|
||||
YELLOW='\033[38;5;3m' ## 鸭屎黄
|
||||
MAGENTA='\033[38;5;5m' ## 基佬紫
|
||||
CYAN='\033[38;5;6m' ## 天依蓝
|
||||
SplitLine="--------------------------------------------------------------------------------"
|
||||
# Functions
|
||||
|
||||
########################
|
||||
# Print to STDERR
|
||||
# Arguments:
|
||||
# Message to print
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
stderr_print() {
|
||||
# 'is_boolean_yes' is defined in libvalidations.sh, but depends on this file so we cannot source it
|
||||
local bool="${BITNAMI_QUIET:-false}"
|
||||
# comparison is performed without regard to the case of alphabetic characters
|
||||
shopt -s nocasematch
|
||||
if ! [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
|
||||
printf "%b\\n" "${*}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Log message
|
||||
# Arguments:
|
||||
# Message to log
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
log() {
|
||||
stderr_print "${CYAN}${MODULE:-} ${MAGENTA}$(date "+%Y-%m-%d %H:%M:%S.%2N ")${RESET}${*}"
|
||||
}
|
||||
########################
|
||||
# Log an 'info' message
|
||||
# Arguments:
|
||||
# Message to log
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
info() {
|
||||
log "${GREEN}INFO ${RESET} ==> ${*}"
|
||||
}
|
||||
########################
|
||||
# Log message
|
||||
# Arguments:
|
||||
# Message to log
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
warn() {
|
||||
log "${YELLOW}WARN ${RESET} ==> ${*}"
|
||||
}
|
||||
########################
|
||||
# Log an 'error' message
|
||||
# Arguments:
|
||||
# Message to log
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
error() {
|
||||
log "${RED}ERROR${RESET} ==> ${*}"
|
||||
}
|
||||
########################
|
||||
# Log a 'debug' message
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
debug() {
|
||||
# 'is_boolean_yes' is defined in libvalidations.sh, but depends on this file so we cannot source it
|
||||
local bool="${BITNAMI_DEBUG:-true}"
|
||||
# comparison is performed without regard to the case of alphabetic characters
|
||||
shopt -s nocasematch
|
||||
if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
|
||||
log "${MAGENTA}DEBUG${RESET} ==> ${*}"
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Indent a string
|
||||
# Arguments:
|
||||
# $1 - string
|
||||
# $2 - number of indentation characters (default: 4)
|
||||
# $3 - indentation character (default: " ")
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
indent() {
|
||||
local string="${1:-}"
|
||||
local num="${2:?missing num}"
|
||||
local char="${3:-" "}"
|
||||
# Build the indentation unit string
|
||||
local indent_unit=""
|
||||
for ((i = 0; i < num; i++)); do
|
||||
indent_unit="${indent_unit}${char}"
|
||||
done
|
||||
# shellcheck disable=SC2001
|
||||
# Complex regex, see https://github.com/koalaman/shellcheck/wiki/SC2001#exceptions
|
||||
echo "$string" | sed "s/^/${indent_unit}/"
|
||||
}
|
||||
|
||||
RED_COLOR="31m" ## 姨妈红
|
||||
GREEN_COLOR="32m" ## 水鸭青
|
||||
YELLOW_COLOR="33m" ## 鸭屎黄
|
||||
PURPLE_COLOR="35m" ## 基佬紫
|
||||
BLUE_COLOR="36m" ## 天依蓝
|
||||
BlinkGreen_COLOR="32;5m" ## 闪烁的水鸭青
|
||||
BlinkRed_COLOR="31;5m" ## 闪烁的姨妈红
|
||||
BlickPurple_COLOR="35;5m" ## 闪烁的基佬紫
|
||||
BackRed_COLOR="41m" ## 背景红色
|
||||
|
||||
######## 颜色函数方法很精妙 ############
|
||||
colorEcho() {
|
||||
echo -e "\033[${1}${@:2}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
colorEchoGreen() {
|
||||
echo -e "\033[32m${@:1}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
colorEchoBlue() {
|
||||
echo -e "\033[36m${@:1}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
colorEchoYellow() {
|
||||
echo -e "\033[33m${@:1}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
colorEchoRed() {
|
||||
echo -e "\033[31m${@:1}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
colorEchoPurple() {
|
||||
echo -e "\033[35m${@:1}\033[0m" 1>&2
|
||||
}
|
||||
|
||||
SplitLine(){
|
||||
echo ""
|
||||
}
|
||||
|
||||
SplitBlue(){
|
||||
colorEchoBlue ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
SplitGreen(){
|
||||
colorEchoGreen ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
SplitRed(){
|
||||
colorEchoRed ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
SplitPurple(){
|
||||
colorEchoPurple ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
FunctionStart() {
|
||||
colorEcho ${PURPLE_COLOR} ${SplitLine}
|
||||
if [[ $# -gt 0 ]]
|
||||
then
|
||||
colorEchoBlue " $1 "
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
FunctionSuccess() {
|
||||
colorEcho ${GREEN_COLOR} ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
FunctionEnd() {
|
||||
colorEcho ${BlinkGreen_COLOR} ${SplitLine}
|
||||
echo ""
|
||||
}
|
||||
|
||||
154
3-wdd初始化-OSS/lib/wdd-lib-sys.sh
Normal file
154
3-wdd初始化-OSS/lib/wdd-lib-sys.sh
Normal file
@@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
|
||||
# 系统相关
|
||||
linux_release_version=""
|
||||
linux_release=""
|
||||
os_bit=""
|
||||
cmd_install="apt-get -y -qq --allow-downgrades install"
|
||||
cmd_update="apt-get -qq update"
|
||||
cmd_remove="apt-get -y remove"
|
||||
software_updated=0
|
||||
|
||||
# 判断命令是否存在
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# 判定是否是root用户
|
||||
check_root() {
|
||||
FunctionStart "判定Root用户!"
|
||||
if [[ $EUID != 0 ]]; then
|
||||
colorEchoRed "当前非root账号(或没有root权限),无法继续操作,请更换root账号!"
|
||||
colorEchoYellow "使用sudo -命令获取临时root权限(执行后可能会提示输入root密码)"
|
||||
exit 1
|
||||
else
|
||||
log "当前为root账号 !"
|
||||
fi
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
####### 获取系统版本及64位或32位信息
|
||||
check_sys() {
|
||||
FunctionStart "获取系统参数"
|
||||
|
||||
# 获取当前终端的宽度,动态调整分割线的长度
|
||||
# local shell_width=$(stty size | awk '{print $2}')
|
||||
# SplitLine=$(yes "-" | sed "${shell_width}"'q' | tr -d '\n')
|
||||
|
||||
local sys_bit
|
||||
sys_bit=$(uname -m)
|
||||
case $sys_bit in
|
||||
i[36]86)
|
||||
os_bit="32"
|
||||
linux_release="386"
|
||||
;;
|
||||
x86_64)
|
||||
os_bit="64"
|
||||
linux_release="amd64"
|
||||
;;
|
||||
*armv6*)
|
||||
os_bit="arm"
|
||||
linux_release="arm6"
|
||||
;;
|
||||
*armv7*)
|
||||
os_bit="arm"
|
||||
linux_release="arm7"
|
||||
;;
|
||||
*aarch64* | *armv8*)
|
||||
os_bit="arm64"
|
||||
linux_release="arm64"
|
||||
;;
|
||||
*)
|
||||
error "
|
||||
哈哈……这个 辣鸡脚本 不支持你的系统。 (-_-) \n
|
||||
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
|
||||
" && exit 1
|
||||
;;
|
||||
esac
|
||||
log "获取的系统信息如下: OS_BIT => ${os_bit} LinuxRelease => $linux_release"
|
||||
|
||||
## 判定Linux的发行版本
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
linux_release_version="centos"
|
||||
elif cat /etc/issue | grep -Eqi "debian"; then
|
||||
linux_release_version="debian"
|
||||
elif cat /etc/issue | grep -Eqi "ubuntu"; then
|
||||
linux_release_version="ubuntu"
|
||||
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
|
||||
linux_release_version="centos"
|
||||
elif cat /proc/version | grep -Eqi "debian"; then
|
||||
linux_release_version="debian"
|
||||
elif cat /proc/version | grep -Eqi "ubuntu"; then
|
||||
linux_release_version="ubuntu"
|
||||
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
|
||||
linux_release_version="centos"
|
||||
else
|
||||
linux_release_version=""
|
||||
fi
|
||||
log "系统参数信息如下: linux_release_version => $linux_release_version"
|
||||
|
||||
# 判断系统的包管理工具 apt, yum, or zypper
|
||||
get_package_manage_tool() {
|
||||
if [[ -n $(command -v apt-get) ]]; then
|
||||
cmd_install="apt-get -y -qq install"
|
||||
cmd_update="apt-get -qq update"
|
||||
cmd_remove="apt-get -y remove"
|
||||
elif [[ -n $(command -v yum) ]]; then
|
||||
cmd_install="yum -y -q install"
|
||||
cmd_update="yum -q makecache"
|
||||
cmd_remove="yum -y remove"
|
||||
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
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# 检查系统包管理方式,更新包
|
||||
get_package_manage_tool
|
||||
if [[ $? -eq 1 ]]; then
|
||||
error "系统的包管理不是 APT or YUM, 请手动安装所需要的软件."
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "系统包管理工具为 => $cmd_install"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [[ $is_offline == 1 ]]; then
|
||||
FunctionEnd
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
### 更新程序引索
|
||||
if [[ $software_updated -eq 0 ]]; then
|
||||
log "正在更新软件包管理...可能花费较长时间…………"
|
||||
$cmd_update
|
||||
software_updated=1
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
# main
|
||||
main() {
|
||||
log "sys脚本被调用了!"
|
||||
}
|
||||
|
||||
main
|
||||
475
3-wdd初始化-OSS/mid-script.sh
Normal file
475
3-wdd初始化-OSS/mid-script.sh
Normal file
@@ -0,0 +1,475 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
## 对外暴露的安装Redis的主函数
|
||||
install_redis() {
|
||||
FunctionStart
|
||||
local redis_port="6379"
|
||||
local redis_install_method="binary"
|
||||
local redis_install_help="0"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-p | --port)
|
||||
redis_port="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-m | --method)
|
||||
redis_install_method="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-h | --help)
|
||||
redis_install_help="1"
|
||||
;;
|
||||
*)
|
||||
echo "输入的内容有误,请检查!"
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
if [ "${redis_install_help}" -eq "1" ]; then
|
||||
cat - 1>&2 <<EOF
|
||||
./install-release.sh [-h] [-p|--port 6379] [-m|--method binary|docker]
|
||||
-h, --help 打印此安装帮助说明
|
||||
-p, --port 安装Redis的端口,如果不指定此参数,则默为6379
|
||||
-m, --method 安装Redis的方式,binary == 源码编译安装,docker == 使用docker安装;不指定则使用binary
|
||||
EOF
|
||||
fi
|
||||
|
||||
# echo $redis_port
|
||||
# echo $redis_install_method
|
||||
|
||||
if [[ ${redis_install_method} == "binary" ]]; then
|
||||
install_redis_binary "${redis_port}"
|
||||
else
|
||||
install_redis_docker "${redis_port}"
|
||||
fi
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# redis_port
|
||||
# Arguments:
|
||||
# 1
|
||||
# Returns:
|
||||
# 3 ...
|
||||
#######################################
|
||||
install_redis_binary() {
|
||||
redis_port=""
|
||||
if [[ $1 -ne " " ]]; then
|
||||
redis_port="$1"
|
||||
echo "Redis Port = ${redis_port}"
|
||||
fi
|
||||
|
||||
echo "InstallRedisBinary"
|
||||
|
||||
CMD_REMOVE gcc
|
||||
installDemandSoftwares gcc wget
|
||||
|
||||
echo "开始下载 Redis 6.2.6 的二进制包!"
|
||||
wget https://oss.107421.xyz/redis-6.2.6.tar.gz
|
||||
|
||||
if [ -e redis-6.2.6.tar.gz ]; then
|
||||
echo "redis源码包下载完成!"
|
||||
echo ""
|
||||
echo "开始解压缩redis的安装包!"
|
||||
tar -zvxf redis-6.2.6.tar.gz
|
||||
cd redis-6.2.6
|
||||
clear
|
||||
echo ""
|
||||
echo ""
|
||||
echo "开始执行编译安装过程!!"
|
||||
echo "开始执行编译安装过程!!"
|
||||
echo "开始执行编译安装过程!!"
|
||||
echo "取决于服务器的性能,可能花费较长的时间!!!"
|
||||
sleep 3
|
||||
echo ""
|
||||
./configure
|
||||
make && make install
|
||||
cd redis-6.2.6
|
||||
|
||||
echo "Redis已经安装成功!!"
|
||||
ehco "开始进行redis的配置修改!!"
|
||||
wget https://oss.107421.xyz/redis-6.2.6.conf
|
||||
wget https://oss.107421.xyz/redis-server-6.2.6.service
|
||||
|
||||
if [ -e redis-6.2.6.conf ] && [ -e redis-server-6.2.6.service ]; then
|
||||
echo "redis配置文件下载成功,开始进行修改!!"
|
||||
echo ""
|
||||
touch /var/log/redis_${redis_port}.log
|
||||
mkdir -p /var/redis/${redis_port}
|
||||
mkdir -p /etc/redis/
|
||||
|
||||
sed -i "s/RedisPort/${redis_port}/g" redis-6.2.6.conf
|
||||
cp redis-6.2.6.conf /etc/redis/${redis_port}.conf
|
||||
|
||||
sed -i "s/RedisPort/${redis_port}/g" redis-server-6.2.6.service
|
||||
cp redis-server-6.2.6.service /etc/init.d/redisd
|
||||
|
||||
cd /etc/init.d
|
||||
chmod +x /etc/init.d/redisd
|
||||
|
||||
if command_exists chkconfig ; then
|
||||
chkconfig redisd on
|
||||
elif command_exists update-rc.d ; then
|
||||
update-rc.d redisd defaults
|
||||
else
|
||||
echo "所需要的守护程序未安装,请手动设置!!"
|
||||
fi
|
||||
|
||||
# 启动程序
|
||||
echo ""
|
||||
echo "开始启动redis-server服务……"
|
||||
service redisd start
|
||||
|
||||
service redisd status
|
||||
|
||||
netstat -ntlp | grep redis
|
||||
|
||||
else
|
||||
echo "redis配置文件下载失败!!请手动进行修改!!"
|
||||
return 3
|
||||
fi
|
||||
else
|
||||
echo "redis源码包下载失败!"
|
||||
return 3
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# RED
|
||||
# redis_port
|
||||
# Arguments:
|
||||
# 1
|
||||
# Returns:
|
||||
# 3 ...
|
||||
#######################################
|
||||
install_redis_docker() {
|
||||
redis_port=""
|
||||
if [[ $1 -ne " " ]]; then
|
||||
redis_port="$1"
|
||||
echo "Redis Port = ${redis_port}"
|
||||
fi
|
||||
|
||||
echo "InstallRedisDocker"
|
||||
echo ""
|
||||
|
||||
if ! command_exists "docker info" ; then
|
||||
colorEcho ${RED} "docker 未安装!! 无法使用docker的方式安装 redis!"
|
||||
return 3
|
||||
fi
|
||||
|
||||
echo "## 为redis配置添加 " >>/etc/sysctl.conf
|
||||
echo "vm.overcommit_memory = 1" >>/etc/sysctl.conf
|
||||
sysctl -p /etc/sysctl.conf
|
||||
|
||||
echo "开始启动docker-redis !!"
|
||||
# https://hub.docker.com/r/bitnami/redis#configuration
|
||||
|
||||
# 为redis设置密码 -e REDIS_PASSWORD=v2ryStr@ngPa.ss \
|
||||
docker run -d \
|
||||
-e ALLOW_EMPTY_PASSWORD=yes \
|
||||
-e REDIS_AOF_ENABLED=no \
|
||||
-e REDIS_PORT_NUMBER=${redis_port} \
|
||||
--name redis-server \
|
||||
--network host \
|
||||
bitnami/redis:6.2.6
|
||||
}
|
||||
|
||||
InstallMysql() {
|
||||
FunctionStart
|
||||
MysqlPort="3306"
|
||||
MysqlInstallMethod="binary"
|
||||
MysqlInstallHelp="0"
|
||||
MysqlPersistData="/var/lib/docker/mysql-data"
|
||||
|
||||
colorEcho ${BLUE} "本脚本默认安装版本为 8.0.27 的MySQL !!"
|
||||
colorEcho ${BLUE} "本脚本默认安装版本为 8.0.27 的MySQL !!"
|
||||
colorEcho ${BLUE} "本脚本默认安装版本为 8.0.27 的MySQL !!"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-p | --port)
|
||||
MysqlPort="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-m | --method)
|
||||
MysqlInstallMethod="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-d | --data)
|
||||
MysqlPersistData="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-h | --help)
|
||||
MysqlInstallHelp="1"
|
||||
;;
|
||||
*)
|
||||
echo "输入的内容有误,请检查!"
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
if [ "${MysqlInstallHelp}" -eq "1" ]; then
|
||||
cat - 1>&2 <<EOF
|
||||
./install-release.sh [-h] [-p|--port 3306] [-m|--method binary|docker]
|
||||
-h, --help 打印此安装帮助说明
|
||||
-p, --port 安装Mysql的端口,如果不指定此参数,则默为3306
|
||||
-m, --method 安装Mysql的方式,binary == 源码编译安装,docker == 使用docker安装;不指定则使用binary
|
||||
EOF
|
||||
return 0
|
||||
fi
|
||||
|
||||
# echo $MysqlPort
|
||||
# echo $MysqlInstallMethod
|
||||
|
||||
if [[ ${MysqlInstallMethod} == "binary" ]]; then
|
||||
installMysqlBinary ${MysqlPort}
|
||||
else
|
||||
installMysqlDocker ${MysqlPort} ${MysqlPersistData}
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
installMysqlBinary() {
|
||||
MysqlPort=""
|
||||
Latest_Mysql_Version=""
|
||||
|
||||
if [[ $1 -ne " " ]]; then
|
||||
MysqlPort="$1"
|
||||
echo "mysql Port = ${MysqlPort}"
|
||||
fi
|
||||
|
||||
echo "InstallMysqlBinary"
|
||||
|
||||
if [[ ${LinuxReleaseVersion} == "centos" ]]; then
|
||||
colorEcho ${BLUE} "当前系统发行版为 centos !"
|
||||
colorEcho ${BLUE} "开始安装mysql官方的yum源!!"
|
||||
echo ""
|
||||
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
|
||||
|
||||
colorEcho ${BLUE} "可以安装的 mysql-server 版本为:"
|
||||
yum list mysql-community-server | grep mysql-community-server
|
||||
echo ""
|
||||
Latest_Mysql_Version=$(yum list mysql-community-server | grep mysql-community-server | awk '{print $2}')
|
||||
colorEcho ${BLUE} "开始安装最新版本:"
|
||||
installDemandSoftwares mysql-community-server-${Latest_Mysql_Version} mysql-community-server-${Latest_Mysql_Version}
|
||||
else
|
||||
colorEcho ${BLUE} "当前系统发行版为 ubuntu/debain !"
|
||||
colorEcho ${BLUE} "可以安装的 mysql-server 版本为:"
|
||||
apt-cache madison mysql-server | awk '{print$3}'
|
||||
echo ""
|
||||
Latest_Mysql_Version=$(apt-cache madison mysql-server | head -n 1 | awk '{print$3}')
|
||||
colorEcho ${BLUE} "开始安装最新版本:${Latest_Mysql_Version}"
|
||||
|
||||
installDemandSoftwares mysql-server=${Latest_Mysql_Version} mysql-client=${Latest_Mysql_Version}
|
||||
fi
|
||||
|
||||
FunctionSuccess
|
||||
colorEcho ${BLUE} "准备启动Mysql Server的服务 !!!"
|
||||
systemctl start mysqld
|
||||
FunctionSuccess
|
||||
colorEcho ${BLUE} "准备配置Mysql 服务的开机启动 !!!"
|
||||
systemctl enable mysqld
|
||||
FunctionSuccess
|
||||
}
|
||||
|
||||
installMysqlDocker() {
|
||||
MysqlPort=""
|
||||
MysqlPersistData=""
|
||||
|
||||
MysqlPort="$1"
|
||||
echo "mysql Port = ${MysqlPort}"
|
||||
|
||||
MysqlPersistData="$2"
|
||||
echo "mysql persist data path = ${MysqlPersistData}"
|
||||
|
||||
echo "InstallMysqlDocker"
|
||||
echo ""
|
||||
|
||||
echo "开始启动docker-mysql !!"
|
||||
# https://hub.docker.com/r/bitnami/mysql#configuration
|
||||
# 需要准备一个目录方式 mysql.conf文件
|
||||
# 目录权限需要处理
|
||||
mkdir -p ${MysqlPersistData}
|
||||
chown -R 1001:1001 ${MysqlPersistData}
|
||||
|
||||
docker run -d \
|
||||
-e MYSQL_ROOT_USER=root \
|
||||
-e MYSQL_ROOT_PASSWORD=v2ryStr@ngPa.ss \
|
||||
-e MYSQL_CHARACTER_SET=utf8mb4 \
|
||||
-e MYSQL_COLLATE=utf8mb4_bin \
|
||||
-e MYSQL_DATABASE=demo \
|
||||
-e MYSQL_USER=wdd \
|
||||
-e MYSQL_PASSWORD=wdd14Fk@Clever \
|
||||
-e MYSQL_PORT_NUMBER=${MysqlPort} \
|
||||
-e MYSQL_AUTHENTICATION_PLUGIN=mysql_native_password \
|
||||
-v ${MysqlPersistData}:/bitnami/mysql/data \
|
||||
--name mysql-server \
|
||||
--network host \
|
||||
bitnami/mysql:8.0.27-debian-10-r40
|
||||
|
||||
}
|
||||
|
||||
## 对外暴露的安装JDK的主函数
|
||||
InstallJDK() {
|
||||
FunctionStart
|
||||
JDK_VERSION="11"
|
||||
JDK_Install_Method="binary"
|
||||
JDKInstallHelp="0"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-v | --version)
|
||||
JDK_VERSION="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-m | --method)
|
||||
JDK_Install_Method="${2}"
|
||||
shift # past argument
|
||||
;;
|
||||
-h | --help)
|
||||
JDKInstallHelp="1"
|
||||
;;
|
||||
*)
|
||||
echo "输入的内容有误,请检查!"
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
if [ "${JDKInstallHelp}" -eq "1" ]; then
|
||||
cat - 1>&2 <<EOF
|
||||
./install-release.sh [-h] [-p|--Version 6379] [-m|--method binary|docker]
|
||||
-h, --help 打印此安装帮助说明
|
||||
-v, --version 安装JDK的版本,如果不指定此参数,则默为11
|
||||
-m, --method 安装JDK的方式,binary == 源码编译安装,package == 使用源,package安装;不指定则使用binary
|
||||
EOF
|
||||
return 0
|
||||
fi
|
||||
|
||||
# echo $JDKVersion
|
||||
# echo $JDKInstallMethod
|
||||
|
||||
if [[ ${JDK_Install_Method} == "binary" ]]; then
|
||||
installJDKBinary ${JDK_VERSION}
|
||||
else
|
||||
installJDKPackage ${JDK_VERSION}
|
||||
fi
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
installJDKBinary() {
|
||||
JDK_VERSION=""
|
||||
JDK_FILENAME=""
|
||||
if [[ $1 -ne " " ]]; then
|
||||
JDK_VERSION="$1"
|
||||
echo "JDK Version = ${JDK_VERSION}"
|
||||
fi
|
||||
|
||||
echo "InstallJDKBinary"
|
||||
echo ""
|
||||
|
||||
echo "开始下载 JDK 的源码包!!"
|
||||
|
||||
mkdir -p /usr/local/java/
|
||||
|
||||
if [ "${JDK_VERSION}" -eq "11" ]; then
|
||||
JDK_FILENAME="jdk-11.0.9"
|
||||
wget https://oss-s1.107421.xyz/jdk-11.0.9_linux-x64_bin.tar.gz
|
||||
echo "JDK 二进制文件下载成功,开始解压缩!!"
|
||||
tar -zxvf jdk-11.0.9_linux-x64_bin.tar.gz -C /usr/local/java/
|
||||
|
||||
else
|
||||
JDK_FILENAME="jdk1.8.0_271"
|
||||
wget https://oss.107421.xyz/jdk-8u271-linux-x64.tar.gz
|
||||
echo "JDK 二进制文件下载成功,开始解压缩!!"
|
||||
tar -zxvf jdk-8u271-linux-x64.tar.gz -C /usr/local/java/
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "开始配置JDK的环境变量!!!"
|
||||
if [ -e /etc/profile.d/jdk-env.sh ]; then
|
||||
echo "jdk的配置文件已经存在!,将会进行覆盖操作!"
|
||||
cp /etc/profile.d/jdk-env.sh .jdk-env-backup.sh
|
||||
|
||||
rm /usr/bin/java
|
||||
fi
|
||||
|
||||
cat >/etc/profile.d/jdk-env.sh <<EOF
|
||||
export JAVA_HOME=/usr/local/java/${JDK_FILENAME}
|
||||
export JRE_HOME=${JAVA_HOME}/jre
|
||||
export CLASSPATH=${JAVA_HOME}/lib:${JRE_HOME}/lib:${CLASSPATH}
|
||||
export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:${PATH}
|
||||
EOF
|
||||
source /etc/profile
|
||||
ln -s /usr/local/java/${JDK_FILENAME}/bin/java /usr/bin/java
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "请检查JDK的安装情况======================================"
|
||||
java -version
|
||||
}
|
||||
|
||||
installJDKPackage() {
|
||||
JDK_VERSION=""
|
||||
if [[ $1 -ne " " ]]; then
|
||||
JDK_VERSION="$1"
|
||||
echo "JDK Version = ${JDK_VERSION}"
|
||||
fi
|
||||
|
||||
echo "InstallJDKDocker"
|
||||
echo ""
|
||||
|
||||
if [[ ${LinuxReleaseVersion} == "centos" ]]; then
|
||||
colorEcho ${BLUE} "当前系统发行版为 centos !"
|
||||
colorEcho ${BLUE} "可以安装的 openjdk 版本为:"
|
||||
yum list java-${JDK_VERSION}-openjdk | grep ${JDK_VERSION}
|
||||
echo ""
|
||||
colorEcho ${BLUE} "开始安装最新版本:$(yum list java-${JDK_VERSION}-openjdk | grep ${JDK_VERSION} | awk '{print $2}' | cut -d':' -f2 | head -n 1)"
|
||||
installDemandSoftwares java-${JDK_VERSION}-openjdk-$(yum list java-${JDK_VERSION}-openjdk | grep ${JDK_VERSION} | awk '{print $2}' | cut -d':' -f2 | head -n 1)
|
||||
else
|
||||
colorEcho ${BLUE} "当前系统发行版为 ubuntu/debain !"
|
||||
colorEcho ${BLUE} "可以安装的 openjdk 版本为:"
|
||||
apt-cache madison openjdk-${JDK_VERSION}-jdk | awk '{print$3}'
|
||||
echo ""
|
||||
colorEcho ${BLUE} "开始安装最新版本:$(apt-cache madison openjdk-${JDK_VERSION}-jdk | head -n 1 | awk '{print$3}')"
|
||||
|
||||
installDemandSoftwares openjdk-${JDK_VERSION}-jdk=$(apt-cache madison openjdk-${JDK_VERSION}-jdk | head -n 1 | awk '{print$3}')
|
||||
|
||||
fi
|
||||
|
||||
colorEcho ${BLUE} "请检查下面的内容输出!!!"
|
||||
java -version
|
||||
|
||||
}
|
||||
|
||||
install_golang_1.21.3(){
|
||||
FunctionStart "开始安装Golang运行环境!"
|
||||
|
||||
wget --timeout=10 -q https://go.dev/dl/go1.21.3.linux-amd64.tar.gz
|
||||
|
||||
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.3.linux-amd64.tar.gz
|
||||
|
||||
log "开始配置环境变量!"
|
||||
sed -i "$ a export GOPATH=/usr/local/go" /etc/profile
|
||||
sed -i "$ a PATH=$PATH:/usr/local/go/bin" /etc/profile
|
||||
|
||||
source /etc/profile
|
||||
|
||||
log "查看golang的版本!"
|
||||
go version
|
||||
|
||||
}
|
||||
42
3-wdd初始化-OSS/sync-base-script.ps1
Normal file
42
3-wdd初始化-OSS/sync-base-script.ps1
Normal file
@@ -0,0 +1,42 @@
|
||||
function SayHello
|
||||
{
|
||||
param (
|
||||
[string]$Name
|
||||
)
|
||||
Write-Host "Hello, $Name!"
|
||||
}
|
||||
|
||||
# 调用函数
|
||||
SayHello -Name "Test PowerShell"
|
||||
|
||||
function SetMinioAlias
|
||||
{
|
||||
# mc.exe alias set local http://10.250.0.100:9000 cmii B#923fC7mk
|
||||
mc.exe alias set tc-sh http://42.192.52.227:9000 cmii B#923fC7mk
|
||||
mc.exe alias set seoul-1 https://cnk8d6fazu16.compat.objectstorage.ap-seoul-1.oraclecloud.com aed62d24d85e2da809ce02bf272420ba4ed74820 rQdEcn69K049+JkA1IGoQmC1k8zma8zfWvZvVS0h144=
|
||||
}
|
||||
|
||||
SetMinioAlias
|
||||
|
||||
# 获取当前工作目录
|
||||
$currentDirectory = Get-Location
|
||||
# 打印当前工作目录
|
||||
Write-Host "Current directory: $currentDirectory"
|
||||
Write-Host ""
|
||||
|
||||
# 获取当前目录的所有文件名
|
||||
$files = Get-ChildItem -Path $currentDirectory -Recurse -File -Name
|
||||
|
||||
# 遍历并打印文件名
|
||||
foreach ($file in $files)
|
||||
{
|
||||
Write-Output $currentDirectory\$file
|
||||
Write-Host ""
|
||||
# mc.exe cp $currentDirectory\$file local/octopus/
|
||||
mc.exe cp $currentDirectory\$file tc-sh/octopus/
|
||||
mc.exe cp $currentDirectory\$file seoul-1/seoul/
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Octopus Agent all dependency file has been synchronized!"
|
||||
7
3-wdd初始化-OSS/初始化脚本使用方法.txt
Normal file
7
3-wdd初始化-OSS/初始化脚本使用方法.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
# 本目录下的全部文件都会被上传到OSS中
|
||||
|
||||
# linux使用
|
||||
bash <(curl -sSL http://oss-s1.107421.xyz/init-script-wdd.sh) --help
|
||||
|
||||
bash <(curl -sSL http://oss-s1.107421.xyz/init-script-wdd.sh) --tools --host --time --ssh-login --ssh-port 22333 --zsh
|
||||
Reference in New Issue
Block a user