forked from Mrmineduce21/Oracle_OneKey_Active
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOneKey_FuckMemory.sh
87 lines (68 loc) · 2.59 KB
/
OneKey_FuckMemory.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
G="G"
cur_dir=$(pwd)
check() {
# check root
[[ $EUID -ne 0 ]] && echo -e "${red}错误:${plain} 必须使用root用户运行此脚本!\n" && exit 1
# check os
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
else
echo -e "${red}未检测到系统版本,请联系脚本作者!${plain}\n" && exit 1
fi
}
install_base() {
echo -e "${yellow}install_base${plain} "
if [[ x"${release}" == x"centos" ]]; then
yum install epel-release -y
yum install wget socat -y
else
apt-get install wget socat -y
fi
}
Fuck_Memory() {
freeMem=$(free -t | awk 'NR ==2 {print $4/1000/1000}')
TCMem=$(free -t | awk 'NR ==2 {print $4/1000/1000/10}') && full=$((${TCMem//.*/+1}))
fullG=${full}$G
echo -e "${green}当前获取到的可用内存为_${freeMem}GB ${plain}"
echo -e "${green}预计填充的内存为_${fullG} ${plain}"
echo -e "${green}===============================${plain} "
echo -e "${yellow} 脚本将自动获取系统可用内存的10%(不满1G按1G算) 并消耗掉这部分内存 ${plain} "
echo -e "${red} 警告:Amd服务器(内存小于2G)请勿使用此脚本,对此照成的封号,机器失联,卡死等问题作者概不负责 ${plain} "
echo -e "${red} 输入数字14运行即表示同意 ${plain} "
read -p "请输入: " -t 30 rules
if (( $rules == 14 )); then
echo -e "${green} 开始运行 ${plain} "
echo -e "${fullG}"
else
echo -e "${red}不同意别用!${plain}\n" && exit 1
fi
#运行部分
if [ -f /root/memory_usage.sh ]; then
echo "file found...开始执行 吃掉内存"
cd /root && wget -qO memory_usage.sh https://raw.githubusercontent.com/Mrmineduce21/Oracle_OneKey_Active/main/memory_usage.sh && chmod +x memory_usage.sh && bash memory_usage.sh consume 2G
else
echo "no such file!-开始下载"
cd /root && wget -qO memory_usage.sh https://raw.githubusercontent.com/Mrmineduce21/Oracle_OneKey_Active/main/memory_usage.sh && chmod +x memory_usage.sh && bash memory_usage.sh consume 2G
fi
}
echo -e "${green}开始运行${plain}"
check
install_base
Fuck_Memory