更新一下,待测试

This commit is contained in:
ert
2025-12-21 01:03:59 +08:00
parent b0d55d7348
commit 301d93c31f
3 changed files with 136 additions and 78 deletions

View File

@@ -1,6 +1,6 @@
# Ubuntu 命令行工具
# Linux 命令行工具
一个适用于Ubuntu的多功能命令行工具提供系统管理、网络配置和rinetd管理等功能。
一个适用于多种Linux发行版的多功能命令行工具提供系统管理、网络配置和rinetd管理等功能支持Ubuntu、Debian、CentOS等系统
## 功能特点
@@ -24,15 +24,34 @@
- 添加中转配置
- 修改中转配置
- 删除中转配置
- 配置修改后自动重启rinetd服务
### 4. 网络工具
### 4. 系统配置
- 查看CPU使用率
- 查看内存使用率
- 查看磁盘使用率
- 查看系统负载
- 查看登录用户信息
- 查看系统服务状态
### 5. 网络工具
- 网络测速 (speedtest-cli)
- 端口扫描 (nmap)
- 查看网络连接 (netstat/ss)
- DNS测试 (dig)
- 路由追踪 (traceroute)
- Ping测试
- 域名解析测试
- 网络流量监控
- 查看MAC地址
- 查看ARP表
- 自动安装缺失的网络工具
### 6. 其他功能
- 多语言支持(中文/英文)
- 脚本自动更新
- 支持多种Linux发行版
## 安装和使用
### 自动安装运行(推荐)
@@ -69,12 +88,13 @@ sudo ./linux_tool.sh
## 注意事项
- 建议使用sudo权限运行脚本因为部分功能需要管理员权限
- 系统更新功能会自动处理不同Ubuntu版本的更新
- rinetd配置修改后需要重启rinetd才能生效
- 系统更新功能会自动检测并适应不同Linux发行版
- rinetd配置修改后会自动重启服务,无需手动操作
- 使用前请确保了解各功能的作用,避免误操作
## 支持的Ubuntu版本
## 支持的Linux发行版
### Ubuntu
- Ubuntu 14.04 LTS (Trusty Tahr)
- Ubuntu 16.04 LTS (Xenial Xerus)
- Ubuntu 18.04 LTS (Bionic Beaver)
@@ -83,6 +103,20 @@ sudo ./linux_tool.sh
- Ubuntu 24.04 LTS (Noble Numbat)
- Ubuntu 24.10 (Oracular Oriole)
### Debian
- Debian 8 LTS (Jessie)
- Debian 9 LTS (Stretch)
- Debian 10 LTS (Buster)
- Debian 11 LTS (Bullseye)
- Debian 12 LTS (Bookworm)
- Debian 13 (Trixie)
- Debian 14 (Forky)
### 其他支持的系统
- CentOS 6/7 (yum)
- CentOS 8+ / Fedora (dnf)
- 其他使用apt/yum/dnf包管理器的Linux发行版
## 许可证
MIT License

16
TODO.md
View File

@@ -15,15 +15,19 @@
- [x] 实现脚本的自动更新功能
- [x] 添加更多系统版本的支持
- [x] 支持更多网络工具的集成
## 待优化
- [x] 添加更多网络工具功能
- [x] 优化脚本性能
- [x] 添加更多系统配置选项
- [x] 实现脚本的多语言支持
- [x] 支持多种Linux发行版
- [x] rinetd配置修改后自动重启服务
## 未来改进方向
- 添加更多语言支持
- 实现配置文件保存功能
- 添加更多系统管理工具
- 优化用户界面和交互体验
- [ ] 添加更多语言支持
- [ ] 实现配置文件保存功能
- [ ] 添加更多系统管理工具
- [ ] 优化用户界面和交互体验
- [ ] 支持更多包管理器
- [ ] 添加更多安全相关功能
- [ ] 实现批量操作功能
- [ ] 添加定时任务功能

View File

@@ -661,10 +661,10 @@ system_config() {
show_menu() {
clear
echo -e "${CYAN}==========================================${NC}"
echo -e "${GREEN} $(__) title ${NC}"
echo -e "${GREEN} $(__ title) ${NC}"
echo -e "${CYAN}==========================================${NC}"
echo -e "${PURPLE} $(__) copyright ${NC}"
echo -e "${BLUE} $(__) website ${NC}"
echo -e "${PURPLE} $(__ copyright) ${NC}"
echo -e "${BLUE} $(__ website) ${NC}"
echo -e "${CYAN}==========================================${NC}"
echo -e "${YELLOW}$(__ menu_1)${NC}"
echo -e "${YELLOW}$(__ menu_2)${NC}"
@@ -755,7 +755,8 @@ modify_max_connections() {
read -n 1
}
# 支持的Ubuntu版本列表
# 支持的Linux发行版和版本
# Ubuntu
declare -A SUPPORTED_UBUNTU_VERSIONS=(
["trusty"]="14.04 LTS"
["xenial"]="16.04 LTS"
@@ -766,6 +767,17 @@ declare -A SUPPORTED_UBUNTU_VERSIONS=(
["oracular"]="24.10"
)
# Debian
declare -A SUPPORTED_DEBIAN_VERSIONS=(
["jessie"]="8 LTS"
["stretch"]="9 LTS"
["buster"]="10 LTS"
["bullseye"]="11 LTS"
["bookworm"]="12 LTS"
["trixie"]="13"
["forky"]="14"
)
# 系统更新功能
system_update() {
clear
@@ -773,84 +785,92 @@ system_update() {
echo -e "${GREEN} 系统更新 ${NC}"
echo -e "${CYAN}==========================================${NC}"
# 获取当前系统信息
OS_NAME=$(lsb_release -i | cut -f2)
CURRENT_VERSION=$(lsb_release -c | cut -f2)
CURRENT_RELEASE=$(lsb_release -r | cut -f2)
# 检测Linux发行版
if command -v lsb_release &> /dev/null; then
OS_NAME=$(lsb_release -i | cut -f2)
CURRENT_VERSION=$(lsb_release -c | cut -f2)
CURRENT_RELEASE=$(lsb_release -r | cut -f2)
elif [ -f /etc/os-release ]; then
source /etc/os-release
OS_NAME=$NAME
CURRENT_VERSION=$VERSION_CODENAME
CURRENT_RELEASE=$VERSION_ID
else
echo -e "${RED}无法检测系统版本!${NC}"
log_message "ERROR" "无法检测系统版本"
read -n 1 -p "按任意键返回菜单..."
return 1
fi
echo -e "${YELLOW}当前系统: ${OS_NAME} ${CURRENT_RELEASE} (${CURRENT_VERSION})${NC}"
# 检查是否为Ubuntu系统
if [ "$OS_NAME" != "Ubuntu" ]; then
echo -e "${RED}警告当前系统不是Ubuntu部分功能可能无法正常使用${NC}"
echo -e "${YELLOW}继续执行更新?(y/n): ${NC}"
read -n 1 confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo -e "${YELLOW}取消更新。${NC}"
read -n 1 -p "按任意键返回菜单..."
return 1
fi
# 确定包管理器
if command -v apt-get &> /dev/null; then
PM="apt"
elif command -v yum &> /dev/null; then
PM="yum"
elif command -v dnf &> /dev/null; then
PM="dnf"
else
echo -e "${RED}不支持的包管理器!${NC}"
log_message "ERROR" "不支持的包管理器"
read -n 1 -p "按任意键返回菜单..."
return 1
fi
echo -e "${YELLOW}支持的Ubuntu版本:${NC}"
for version in "${!SUPPORTED_UBUNTU_VERSIONS[@]}"; do
echo -e " - ${version}: ${SUPPORTED_UBUNTU_VERSIONS[$version]}"
done
echo -e "${YELLOW}包管理器: ${PM}${NC}"
echo -e "\n${YELLOW}1. 自动选择系统版本更新${NC}"
echo -e "${YELLOW}2. 手动选择系统版本更新${NC}"
echo -n -e "${PURPLE}请输入您的选择 [1-2]: ${NC}"
# 显示支持的版本
if [[ "$OS_NAME" == *"Ubuntu"* ]]; then
echo -e "${YELLOW}支持的Ubuntu版本:${NC}"
for version in "${!SUPPORTED_UBUNTU_VERSIONS[@]}"; do
echo -e " - ${version}: ${SUPPORTED_UBUNTU_VERSIONS[$version]}"
done
elif [[ "$OS_NAME" == *"Debian"* ]]; then
echo -e "${YELLOW}支持的Debian版本:${NC}"
for version in "${!SUPPORTED_DEBIAN_VERSIONS[@]}"; do
echo -e " - ${version}: ${SUPPORTED_DEBIAN_VERSIONS[$version]}"
done
fi
echo -e "\n${YELLOW}1. 自动更新${NC}"
echo -n -e "${PURPLE}请输入您的选择 [1]: ${NC}"
read update_choice
case $update_choice in
1)
echo -e "${YELLOW}正在使用当前系统版本 ${CURRENT_VERSION} 进行更新...${NC}"
echo -e "${YELLOW}正在执行系统更新...${NC}"
log_message "INFO" "开始系统更新,当前版本: ${CURRENT_VERSION}"
# 根据Ubuntu版本选择更新命令
if [ "$OS_NAME" == "Ubuntu" ] && [[ " ${!SUPPORTED_UBUNTU_VERSIONS[@]} " =~ " $CURRENT_VERSION " ]]; then
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
else
# 通用更新命令适用于其他Ubuntu版本或Linux发行版
sudo apt-get update || sudo apt update
sudo apt-get upgrade -y || sudo apt upgrade -y
sudo apt-get dist-upgrade -y || sudo apt full-upgrade -y
sudo apt-get autoremove -y || sudo apt autoremove -y
fi
case $PM in
apt)
# apt包管理器 (Debian/Ubuntu)
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
;;
yum)
# yum包管理器 (CentOS 6/7)
sudo yum update -y
sudo yum upgrade -y
;;
dnf)
# dnf包管理器 (CentOS 8+, Fedora)
sudo dnf update -y
sudo dnf upgrade -y
;;
*)
echo -e "${RED}不支持的包管理器!${NC}"
log_message "ERROR" "不支持的包管理器: $PM"
read -n 1 -p "按任意键返回菜单..."
return 1
;;
esac
echo -e "${GREEN}系统更新完成!${NC}"
log_message "INFO" "系统更新完成"
;;
2)
echo -n -e "${PURPLE}请输入要更新的系统版本代号jammy, focal: ${NC}"
read selected_version
if [ "$selected_version" == "$CURRENT_VERSION" ]; then
echo -e "${YELLOW}正在使用选择的系统版本 ${selected_version} 进行更新...${NC}"
log_message "INFO" "开始系统更新,使用选择的版本: ${selected_version}"
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
echo -e "${GREEN}系统更新完成!${NC}"
log_message "INFO" "系统更新完成"
else
# 检查选择的版本是否受支持
if [[ " ${!SUPPORTED_UBUNTU_VERSIONS[@]} " =~ " $selected_version " ]]; then
echo -e "${RED}错误:选择的系统版本 ${selected_version} 与当前系统版本 ${CURRENT_VERSION} 不匹配!${NC}"
echo -e "${YELLOW}当前系统版本: ${CURRENT_VERSION} (${SUPPORTED_UBUNTU_VERSIONS[$CURRENT_VERSION]:-未知版本})${NC}"
echo -e "${YELLOW}选择的版本: ${selected_version} (${SUPPORTED_UBUNTU_VERSIONS[$selected_version]})${NC}"
else
echo -e "${RED}错误:选择的系统版本 ${selected_version} 不是受支持的Ubuntu版本${NC}"
fi
log_message "ERROR" "选择的系统版本无效: ${selected_version}"
fi
;;
*)
echo -e "${RED}无效的选择!${NC}"
log_message "WARNING" "无效的更新选择: ${update_choice}"