Enhance Docker Installation and Management Commands
- Improved Docker installation process for Ubuntu systems - Added support for dynamic Docker version detection - Enhanced Docker local and online installation commands - Implemented more robust Docker removal functionality - Updated Docker installation to use system-specific package sources - Added better error handling and logging for Docker operations - Refined Docker service startup and configuration checks
This commit is contained in:
27
agent-wdd/test/one-click-build-run.ps1
Normal file
27
agent-wdd/test/one-click-build-run.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
# mc.exe alias set oracle-osaka-1 https://axzsapxffbbn.compat.objectstorage.ap-osaka-1.oraclecloud.com b0696c316f87b644b4a13bcb020f095cd147be0b GAIaM/064epLzQcXsRbj2gwlFOrVepjCR23wj2tfJ+A=
|
||||
|
||||
# 重新build项目
|
||||
Set-Location "C:\Users\wddsh\Documents\IdeaProjects\ProjectOctopus\agent-wdd"
|
||||
& "C:\Users\wddsh\go\bin\gox.exe" -osarch="linux/amd64" -output "build/agent-wdd_{{.OS}}_{{.Arch}}"
|
||||
|
||||
|
||||
# mc.exe ls oracle-osaka-1/osaka
|
||||
# 删除上面存在的旧的内容
|
||||
mc.exe rm oracle-osaka-1/osaka/agent-wdd_linux_amd64
|
||||
mc.exe rm oracle-osaka-1/osaka/test-shell.sh
|
||||
|
||||
|
||||
# 上传文件
|
||||
mc.exe cp C:\Users\wddsh\Documents\IdeaProjects\ProjectOctopus\agent-wdd\build\agent-wdd_linux_amd64 oracle-osaka-1/osaka/
|
||||
mc.exe cp C:\Users\wddsh\Documents\IdeaProjects\ProjectOctopus\agent-wdd\test\test-shell.sh oracle-osaka-1/osaka/
|
||||
|
||||
|
||||
Set-Location "C:\Users\wddsh\Documents\IdeaProjects\ProjectOctopus\agent-wdd\test"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
43
agent-wdd/test/readme_help.txt
Normal file
43
agent-wdd/test/readme_help.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
Available commands:
|
||||
|
||||
acme acme相关的内容
|
||||
base 服务器基础操作
|
||||
docker Docker相关操作
|
||||
local 本地安装Docker
|
||||
online 网络安装Docker
|
||||
remove 卸载Docker
|
||||
dockercompose Docker Compose相关操作
|
||||
local 本地安装Docker Compose
|
||||
online 安装Docker Compose
|
||||
remove 卸载Docker Compose
|
||||
version 查看Docker Compose版本
|
||||
firewall 关闭防火墙
|
||||
selinux 关闭selinux
|
||||
ssh 修改ssh配置
|
||||
config 修改ssh配置 为wdd默认配置!
|
||||
key 安装默认的ssh-key
|
||||
port 修改ssh端口
|
||||
swap 关闭系统的Swap
|
||||
sysconfig 修改系统的sysconfig
|
||||
tools 通用工具安装 利用本机的yum,apt等从网络安装常用的软件
|
||||
config 配置文件管理
|
||||
show 显示agent运行配置
|
||||
download 文件下载,直接下载 [url] [dest_path]
|
||||
proxy 使用代理下载 socks5://[username]:[password]@ip:port http://[username]:[password]@ip:port
|
||||
help 帮助信息
|
||||
help Help about any command
|
||||
info 打印主机详细信息
|
||||
all 主机全部相关的信息
|
||||
cpu 主机cpu相关的信息
|
||||
disk 主机disk相关的信息
|
||||
mem 主机memory相关的信息
|
||||
network 主机Network相关的信息
|
||||
os 主机操作系统相关的信息
|
||||
proxy 主机代理相关的内容
|
||||
vmess 设置VMESS代理
|
||||
xray Xray相关操作
|
||||
install 安装Xray
|
||||
security 安全相关操作
|
||||
version 打印版本信息
|
||||
wdd WDD相关操作
|
||||
zsh zsh相关的内容
|
||||
52
agent-wdd/test/run_test.sh
Normal file
52
agent-wdd/test/run_test.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -f /usr/local/bin/agent-wdd
|
||||
rm -f /usr/local/bin/test-shell.sh
|
||||
|
||||
wget https://pan.107421.xyz/d/oracle-osaka-1/agent-wdd_linux_amd64 -O /usr/local/bin/agent-wdd
|
||||
|
||||
chmod +x /usr/local/bin/agent-wdd
|
||||
|
||||
|
||||
wget https://pan.107421.xyz/d/oracle-osaka-1/test-shell.sh -O /usr/local/bin/test-shell.sh
|
||||
|
||||
chmod +x /usr/local/bin/test-shell.sh
|
||||
|
||||
|
||||
|
||||
|
||||
bash /usr/local/bin/test-shell.sh
|
||||
|
||||
|
||||
|
||||
|
||||
/usr/local/bin/agent-wdd info network
|
||||
/usr/local/bin/agent-wdd info cpu
|
||||
/usr/local/bin/agent-wdd info mem
|
||||
/usr/local/bin/agent-wdd info swap
|
||||
/usr/local/bin/agent-wdd info disks
|
||||
|
||||
cat /usr/local/etc/wdd/agent-wdd-config.yaml
|
||||
|
||||
|
||||
/usr/local/bin/agent-wdd base docker local
|
||||
|
||||
/usr/local/bin/agent-wdd info os
|
||||
/usr/local/bin/agent-wdd base docker online
|
||||
|
||||
/usr/local/bin/agent-wdd info os
|
||||
/usr/local/bin/agent-wdd zsh
|
||||
|
||||
/usr/local/bin/agent-wdd base tools
|
||||
|
||||
/usr/local/bin/agent-wdd base swap
|
||||
|
||||
/usr/local/bin/agent-wdd base firewall
|
||||
|
||||
/usr/local/bin/agent-wdd base selinux
|
||||
|
||||
/usr/local/bin/agent-wdd base sysconfig
|
||||
|
||||
|
||||
/usr/local/bin/agent-wdd download https://pan.107421.xyz/d/oracle-osaka-1/docker-amd64-20.10.15.tgz /root/wdd
|
||||
|
||||
135
agent-wdd/test/test-shell.sh
Normal file
135
agent-wdd/test/test-shell.sh
Normal file
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
# set -eo pipefail
|
||||
|
||||
# 测试配置
|
||||
TEST_REPEATS=2
|
||||
AGENT_BIN="/usr/local/bin/agent-wdd" # 修正路径拼写错误
|
||||
|
||||
# 输出颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# 测试统计
|
||||
declare -i TOTAL_TESTS=0 PASSED_TESTS=0 FAILED_TESTS=0
|
||||
|
||||
# 实用函数
|
||||
log() {
|
||||
echo -e "${YELLOW}[INFO] $* ${NC}"
|
||||
}
|
||||
|
||||
pass() {
|
||||
echo -e "${GREEN}PASS: $* ${NC}"
|
||||
((PASSED_TESTS++))
|
||||
((TOTAL_TESTS++))
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo -e "${RED}FAIL: $* ${NC}"
|
||||
((FAILED_TESTS++))
|
||||
((TOTAL_TESTS++))
|
||||
}
|
||||
|
||||
test_command() {
|
||||
local cmd="$1"
|
||||
local expected="${2:-0}"
|
||||
|
||||
if ! eval "$cmd"; then
|
||||
local exit_code=$?
|
||||
[[ $exit_code -eq "$expected" ]] || {
|
||||
fail "$cmd (exit $exit_code)"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
pass "$cmd"
|
||||
return 0
|
||||
}
|
||||
|
||||
repeat_test() {
|
||||
local times=$1
|
||||
local cmd="$2"
|
||||
local expected="${3:-0}"
|
||||
|
||||
for ((i=1; i<=times; i++)); do
|
||||
test_command "$cmd" "$expected"
|
||||
done
|
||||
}
|
||||
|
||||
test_base_docker() {
|
||||
log "\nTesting Docker commands..."
|
||||
test_command "$AGENT_BIN base docker remove" 0
|
||||
test_command "$AGENT_BIN base docker online" 0
|
||||
repeat_test $TEST_REPEATS "$AGENT_BIN base docker local" 0
|
||||
|
||||
if docker --version >/dev/null 2>&1; then
|
||||
pass "docker installation"
|
||||
else
|
||||
fail "docker installation"
|
||||
fi
|
||||
}
|
||||
|
||||
test_base_ssh() {
|
||||
log "\nTesting SSH commands..."
|
||||
repeat_test $TEST_REPEATS "$AGENT_BIN base ssh port 2222" 0
|
||||
test_command "$AGENT_BIN base ssh config" 0
|
||||
}
|
||||
|
||||
test_tools() {
|
||||
log "\nTesting tools installation..."
|
||||
local tools=("htop" "tmux" "nano")
|
||||
for tool in "${tools[@]}"; do
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
pass "$tool already installed"
|
||||
else
|
||||
test_command "$AGENT_BIN base tools $tool" 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
test_info_commands() {
|
||||
log "\nTesting info commands..."
|
||||
local commands=(
|
||||
"$AGENT_BIN info all"
|
||||
"$AGENT_BIN info cpu"
|
||||
"$AGENT_BIN info disk"
|
||||
"$AGENT_BIN info mem"
|
||||
"$AGENT_BIN info network"
|
||||
"$AGENT_BIN info os"
|
||||
)
|
||||
|
||||
for cmd in "${commands[@]}"; do
|
||||
repeat_test $TEST_REPEATS "$cmd" 0
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
# 前置检查
|
||||
[[ -x "$AGENT_BIN" ]] || {
|
||||
log "Error: Agent binary not found or not executable: $AGENT_BIN"
|
||||
exit 1
|
||||
}
|
||||
|
||||
log "Starting tests with $AGENT_BIN..."
|
||||
|
||||
# 基本信息测试
|
||||
test_command "$AGENT_BIN version" 0
|
||||
test_command "$AGENT_BIN help" 0
|
||||
|
||||
# 基础模块测试
|
||||
test_base_docker
|
||||
test_base_ssh
|
||||
test_tools
|
||||
|
||||
# 信息模块测试
|
||||
test_info_commands
|
||||
|
||||
log "\nTest Summary:"
|
||||
echo -e "Total Tests: $TOTAL_TESTS"
|
||||
echo -e "${GREEN}Passed: $PASSED_TESTS ${NC}"
|
||||
echo -e "${RED}Failed: $FAILED_TESTS ${NC}"
|
||||
|
||||
exit "$FAILED_TESTS"
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user