-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlimite.sh
56 lines (56 loc) · 5.44 KB
/
limite.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
#!/bin/bash
userrc=$(echo $1 |sed 's/@/aa/g' |sed 's/-/k/g' |sed 's/0/a/g' |sed 's/1/b/g' |sed 's/2/c/g' |sed 's/3/d/g' |sed 's/4/e/g' |sed 's/5/f/g' |sed 's/6/g/g' |sed 's/7/h/g' |sed 's/8/i/g' |sed 's/9/j/g')
limpcron=$(cat /etc/crontab |grep -v "#$1#")
echo "$limpcron" > /etc/crontab
echo "#!/bin/sh
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
sleep 2.5s
if [ \$(ps -u $1 |grep sshd |wc -l) -gt $2 ]; then ps -u $1 |grep sshd |awk '{print \$1}' > /tmp/sshpid$1; sshpid$userrc=\$(cat -n /tmp/sshpid$1 |awk '\$1 > $2 {print \$2}'); kill \$sshpid$userrc; fi
exit
" > /etc/vpsconf/limite/$1.sh
chmod a+x /etc/vpsconf/limite/$1.sh 2>/dev/null
echo "*/1 * * * * root /etc/vpsconf/limite/$1.sh #$1#" >> /etc/crontab
echo -e "\033[1;37mUsuario: \033[1;31m[\033[1;37m$1\033[1;31m]\033[1;37m Limite: \033[1;31m[\033[1;37m$2\033[1;31m] \033[1;37m[\033[1;31mLimite Aplicado\033[1;37m] \033[0m"
echo "$2" > /etc/vpsconf/limite/$1