init: fork of kejilion/sh with certbot host-network fix
Some checks failed
Weekly Translation Workflow / translate (push) Has been cancelled
Some checks failed
Weekly Translation Workflow / translate (push) Has been cancelled
- Replace 'docker run -p 80:80' with '--network host' for certbot standalone HTTP-01 to avoid timeout in environments where Docker NAT port-publish breaks LE inbound traffic but host port 80 is reachable. - Applies to kejilion.sh (all locale variants) and auto_cert_renewal.sh. - README install command points to this Gitea mirror.
This commit is contained in:
48
Limiting_Shut_down1.sh
Normal file
48
Limiting_Shut_down1.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 获取总的接收流量(只统计公网网卡)
|
||||
rx_output=$(awk 'BEGIN { rx_total = 0 }
|
||||
$1 ~ /^(eth|ens|enp|eno)[0-9]+/ { rx_total += $2 }
|
||||
END {
|
||||
printf("%.0f Bytes", rx_total);
|
||||
}' /proc/net/dev)
|
||||
|
||||
# 获取总的发送流量(只统计公网网卡)
|
||||
tx_output=$(awk 'BEGIN { tx_total = 0 }
|
||||
$1 ~ /^(eth|ens|enp|eno)[0-9]+/ { tx_total += $10 }
|
||||
END {
|
||||
printf("%.0f Bytes", tx_total);
|
||||
}' /proc/net/dev)
|
||||
|
||||
# 获取接收流量数据
|
||||
rx=$(echo "$rx_output" | awk '{print $1}')
|
||||
|
||||
# 获取发送流量数据
|
||||
tx=$(echo "$tx_output" | awk '{print $1}')
|
||||
|
||||
# 显示当前流量使用情况
|
||||
echo "当前接收流量: $rx Bytes"
|
||||
echo "当前发送流量: $tx Bytes"
|
||||
|
||||
rx_threshold_gb=110
|
||||
tx_threshold_gb=120
|
||||
|
||||
# 将GB转换为字节
|
||||
rx_threshold=$((rx_threshold_gb * 1024 * 1024 * 1024))
|
||||
tx_threshold=$((tx_threshold_gb * 1024 * 1024 * 1024))
|
||||
|
||||
# 检查是否达到接收流量阈值
|
||||
if (( rx > rx_threshold )); then
|
||||
echo "接收流量达到${rx_threshold_gb}GB (${rx_threshold} Bytes),正在关闭服务器..."
|
||||
shutdown -h now
|
||||
else
|
||||
echo "当前接收流量未达到${rx_threshold_gb}GB (${rx_threshold} Bytes),继续监视..."
|
||||
fi
|
||||
|
||||
# 检查是否达到发送流量阈值
|
||||
if (( tx > tx_threshold )); then
|
||||
echo "发送流量达到${tx_threshold_gb}GB (${tx_threshold} Bytes),正在关闭服务器..."
|
||||
shutdown -h now
|
||||
else
|
||||
echo "当前发送流量未达到${tx_threshold_gb}GB (${tx_threshold} Bytes),继续监视..."
|
||||
fi
|
||||
Reference in New Issue
Block a user