Skip to content

Commit

Permalink
2024.11.17
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Nov 17, 2024
1 parent f3e10a9 commit 84b0303
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o go
curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
```

安装环境
更新包管理器(可选择)和安装环境

```
./goecs.sh env
Expand Down Expand Up @@ -100,12 +100,12 @@ shell脚本的说明
可用命令:
./goecs.sh env 检查并安装依赖包
警告: 此命令会执行系统更新,可能:
警告: 此命令会执行系统更新(可选择),可能:
1. 耗时较长
2. 导致网络短暂中断
3. 影响系统稳定性
4. 影响后续系统启动
对于内存小于2GB的系统,还可能导致:
对于内存小于1GB的系统,还可能导致:
1. 系统卡死
2. SSH连接中断
3. 关键服务失败
Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ Explanation of the shell script
Available commands:
./goecs.sh env Check and Install dependencies
Warning: This command performs system update, which may:
Warning: This command performs system update(optional), which may:
1. Take considerable time
2. Cause temporary network interruptions
3. Impact system stability
4. Affect subsequent system startups
For systems with less than 2GB RAM, additional risks:
For systems with less than 1GB RAM, additional risks:
1. System freeze
2. SSH connection loss
3. Critical service failures
Expand Down
31 changes: 24 additions & 7 deletions goecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,23 @@ download_file() {
}

get_memory_size() {
local mem_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
echo $((mem_kb / 1024))
if [ -f /proc/meminfo ]; then
local mem_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
echo $((mem_kb / 1024)) # Convert to MB
return
fi
if command -v free >/dev/null 2>&1; then
local mem_kb=$(free -m | awk '/^Mem:/ {print $2}')
echo "$mem_kb" # Already in MB
return
fi
if command -v sysctl >/dev/null 2>&1; then
local mem_bytes=$(sysctl -n hw.memsize 2>/dev/null || sysctl -n hw.physmem 2>/dev/null)
if [ -n "$mem_bytes" ]; then
echo $((mem_bytes / 1024 / 1024)) # Convert to MB
return
fi
fi
}

cleanup_epel() {
Expand Down Expand Up @@ -226,7 +241,9 @@ InstallSysbench() {
Var_OSRelease="unknown" # 未知系统分支
fi
local mem_size=$(get_memory_size)
if [ $mem_size -lt 1024 ]; then
if [ -z "$mem_size" ] || [ "$mem_size" -eq 0 ]; then
echo "Error: Unable to determine memory size or memory size is zero."
elif [ $mem_size -lt 1024 ]; then
_red "Warning: Your system has less than 1GB RAM (${mem_size}MB)"
reading "Do you want to continue with EPEL installation? (y/N): " confirm
if [[ ! $confirm =~ ^[Yy]$ ]]; then
Expand Down Expand Up @@ -469,12 +486,12 @@ show_help() {
可用命令:
./goecs.sh env 检查并安装依赖包
警告: 此命令会执行系统更新,可能:
警告: 此命令会执行系统更新(可选择),可能:
1. 耗时较长
2. 导致网络短暂中断
3. 影响系统稳定性
4. 影响后续系统启动
对于内存小于2GB的系统,还可能导致:
对于内存小于1GB的系统,还可能导致:
1. 系统卡死
2. SSH连接中断
3. 关键服务失败
Expand All @@ -500,12 +517,12 @@ show_help() {
Available commands:
./goecs.sh env Check and Install dependencies
Warning: This command performs system update, which may:
Warning: This command performs system update(optional), which may:
1. Take considerable time
2. Cause temporary network interruptions
3. Impact system stability
4. Affect subsequent system startups
For systems with less than 2GB RAM, additional risks:
For systems with less than 1GB RAM, additional risks:
1. System freeze
2. SSH connection loss
3. Critical service failures
Expand Down

0 comments on commit 84b0303

Please sign in to comment.