小弟不才,手动改写的,复制代码直接粘贴就行!
有系统版本检测,IP地址,BBR,运行时长,本机时间!
如果没有生效的话,执行一下这个命令:chmod +x /etc/profile.d/my-welcome.sh
cat > /etc/profile.d/my-welcome.sh << 'EOF'#!/bin/bash# 只在交互式shell中显示case $- in *i*) ;; *) return;;esac# 定义颜色代码GREEN='\033[0;32m'YELLOW='\033[0;33m'BLUE='\033[0;34m'RED='\033[0;31m'PURPLE='\033[0;35m'NC='\033[0m'# 获取IP地址函数get_public_ip() { local type=$1 local ip=$(curl -s --connect-timeout 2 "http://${type}.icanhazip.com" 2>/dev/null | tr -d '\n\r') if [ -n "$ip" ]; then echo -e "${GREEN}$ip${NC}" else echo -e "${RED}未获取到${NC}" fi}# 检测系统版本get_os_info() { # 检测发行版 if [ -f /etc/os-release ]; then source /etc/os-release if [ -n "$PRETTY_NAME" ]; then echo -e "${PURPLE}$PRETTY_NAME${NC}" else echo -e "${PURPLE}$NAME $VERSION${NC}" fi elif [ -f /etc/redhat-release ]; then echo -e "${PURPLE}$(cat /etc/redhat-release)${NC}" elif [ -f /etc/issue ]; then echo -e "${PURPLE}$(head -n1 /etc/issue | tr -d '\\\r')${NC}" else echo -e "${RED}未知系统${NC}" fi}# 检测内核版本get_kernel_version() { echo -e "${PURPLE}$(uname -r)${NC}"}# 检测BBR状态check_bbr() { local bbr_status=$(sysctl net.ipv4.tcp_congestion_control 2>/dev/null | awk '{print $3}') if [[ "$bbr_status" == "bbr" ]]; then echo -e "${GREEN}已启用${NC}" else echo -e "${RED}未启用${NC}" fi}echo -e "${BLUE}=== 服务器信息 ===${NC}"echo -e "${YELLOW}系统版本:${NC} $(get_os_info)"echo -e "${YELLOW}内核版本:${NC} $(get_kernel_version)"echo -e "${YELLOW}服务器:${NC} $(hostname)"echo -e "${YELLOW}时间:${NC} $(date +"%Y-%m-%d %H:%M:%S")"echo -e "${YELLOW}运行:${NC} $(uptime -p | sed 's/up //')"echo -e "${YELLOW}IPv4:${NC} $(get_public_ip ipv4)"echo -e "${YELLOW}IPv6:${NC} $(get_public_ip ipv6)"echo -e "${YELLOW}BBR:${NC} $(check_bbr)"echo ""EOF
评论 (0)