forked from erfjab/holderbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathholderbot.sh
145 lines (117 loc) · 4 KB
/
holderbot.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
cd && cd ..
sudo apt-get update
sudo apt-get install -y python3-dev
sudo apt-get install -y libsqlite3-dev
sudo apt install build-essential
if ! command -v python3 &> /dev/null; then
echo "Python not found. Installing..."
sudo apt-get install -y python3
fi
if ! command -v git &> /dev/null; then
echo "Git not found. Installing..."
sudo apt-get install -y git
fi
if ! command -v pip3 &> /dev/null; then
echo "pip3 not found. Installing..."
sudo apt-get install -y python3-pip
fi
if [ -d "holderbot" ]; then
echo "Removing existing holderbeta directory..."
rm -rf holderbot
fi
if [ -d "holderbeta" ]; then
echo "Removing existing holderbeta directory..."
rm -rf holderbeta
fi
if [ -d "holder" ]; then
echo "Removing existing holder directory..."
rm -rf holder
fi
if ps aux | grep -v grep | grep "python3 holder.py" &> /dev/null; then
echo "Stopping existing holder process..."
pkill -f "python3 holder.py"
fi
if ps aux | grep -v grep | grep "python3 holderbeta.py" &> /dev/null; then
echo "Stopping existing holder process..."
pkill -f "python3 holderbeta.py"
fi
if ps aux | grep -v grep | grep "python3 node_status_checker.py" &> /dev/null; then
echo "Stopping existing node_status_checker process..."
pkill -f "python3 node_status_checker.py"
fi
if ps aux | grep -v grep | grep "python3 monitoringbeta.py" &> /dev/null; then
echo "Stopping existing monitoringbeta process..."
pkill -f "python3 monitoringbeta.py"
fi
if ps aux | grep -v grep | grep "python3 monitoring.py" &> /dev/null; then
echo "Stopping existing monitoring process..."
pkill -f "python3 monitoring.py"
fi
if ps aux | grep -v grep | grep "python3 expired.py" &> /dev/null; then
echo "Stopping existing expired process..."
pkill -f "python3 expired.py"
fi
if ps aux | grep -v grep | grep "python3 limiteder.py" &> /dev/null; then
echo "Stopping existing limiteder process..."
pkill -f "python3 limiteder.py"
fi
mkdir holderbot
cd holderbot
git clone -b main https://github.com/erfjab/holderbot.git .
sudo apt install -y python3.10-venv
python3 -m venv hold
source hold/bin/activate
pip install -U pyrogram tgcrypto requests Pillow qrcode[pil] persiantools pytz python-dateutil pysqlite3 cdifflib reportlab
sudo apt-get install sqlite3
read -p "Please enter name (nickname) : " name
read -p "Please enter telegram chatid : " chatid
read -p "Please enter telegram bot token: " token
read -p "Please enter panel sudo username : " user
read -p "Please enter panel sudo password : " password
read -p "Please enter panel domain (like: sub.domian.com:port) : " domain
sqlite3 holder.db <<EOF
CREATE TABLE bot
(chatid INTEGER PRIMARY KEY,
token TEXT);
CREATE TABLE monitoring
(chatid INTEGER PRIMARY KEY,
status TEXT,
check_normal INTEGER,
check_error INTEGER);
CREATE TABLE templates
(name TEXT PRIMARY KEY,
data INTEGER,
date INTEGER,
proxies TEXT,
inbounds TEXT);
CREATE TABLE users
(chatid INTEGER PRIMARY KEY,
role TEXT,
name TEXT,
username TEXT,
password TEXT,
domain TEXT,
step TEXT);
CREATE TABLE IF NOT EXISTS messages
(chatid INTEGER PRIMARY KEY,
status TEXT);
INSERT INTO messages (chatid, status) VALUES ('$chatid', 'off');
INSERT INTO users (chatid, role, name, username, password, domain, step) VALUES ('$chatid', 'boss', '$name', '$user', '$password', '$domain', 'None');
INSERT INTO monitoring (chatid, status, check_normal, check_error) VALUES ('$chatid', 'on', '10', '100');
INSERT INTO bot (chatid, token) VALUES ("$chatid", "$token");
EOF
chmod +x monitoring.py
chmod +x holder.py
chmod +x expired.py
chmod +x limiteder.py
nohup python3 monitoring.py & disown
nohup python3 holder.py & disown
nohup python3 expired.py & disown
nohup python3 limiteder.py & disown
chmod +x restart.sh
cronjob="@reboot sleep 20 && /bin/bash /holderbot/restart.sh"
if ! crontab -l | grep -Fq "$cronjob"; then
(crontab -l 2>/dev/null; echo "$cronjob") | crontab -
fi
echo "Holderbot is run!"