Skip to content

Commit 038f5dd

Browse files
authored
add install.sh script
1 parent 8779186 commit 038f5dd

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Rocket.Chat webhook
1616
# -------------------------
1717
def send_to_rocketchat_webhook(message):
18-
print(f"sending new config to RocketChat server.")
18+
print(f"Sending a message to rocketChat.")
1919
data = {"text": message}
2020
try:
2121
time.sleep(1)
@@ -156,7 +156,7 @@ def main():
156156
schedule.every(3).hours.do(main)
157157

158158
while True:
159-
print(f"{time.time()}")
159+
print(f"starting {time.time()}")
160160
schedule.run_pending()
161161
time.sleep(1)
162162

install.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Variables
4+
BOT_DIR="/var/rocketv2rayHunter"
5+
SERVICE_NAME="v2ray-bot.service"
6+
SYSTEMD_DIR="/etc/systemd/system"
7+
8+
# Check for root privileges
9+
if [ "$(id -u)" -ne 0 ]; then
10+
echo "This script must be run as root"
11+
exit 1
12+
fi
13+
14+
# Create the directory for the bot if it doesn't exist
15+
mkdir -p $BOT_DIR
16+
17+
# Move the bot files to the proper location
18+
echo "Moving bot files to $BOT_DIR..."
19+
pip install -r requirements.txt
20+
cp bot.py $BOT_DIR/
21+
cp config.py $BOT_DIR/
22+
23+
# Create the systemd service file
24+
echo "Creating systemd service..."
25+
26+
cat <<EOF > $SYSTEMD_DIR/$SERVICE_NAME
27+
[Unit]
28+
Description=RocketChat V2Ray Hunter
29+
After=network.target
30+
31+
[Service]
32+
ExecStart=/usr/bin/python3 $BOT_DIR/bot.py
33+
WorkingDirectory=$BOT_DIR
34+
User=root
35+
Restart=always
36+
RestartSec=10s
37+
38+
[Install]
39+
WantedBy=multi-user.target
40+
EOF
41+
42+
# Reload systemd to recognize the new service
43+
echo "Reloading systemd..."
44+
systemctl daemon-reload
45+
46+
# Enable the service to start on boot
47+
echo "Enabling the service to start on boot..."
48+
systemctl enable $SERVICE_NAME
49+
50+
# Start the service
51+
echo "Starting the service..."
52+
systemctl start $SERVICE_NAME
53+
54+
# Check service status
55+
echo "Service status:"
56+
systemctl status $SERVICE_NAME
57+
58+
echo "Installation and setup complete!"

systemd/system/v2ray-bot.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=RocketChat V2Ray Hunter
3+
After=network.target
4+
5+
[Service]
6+
ExecStart=/usr/bin/python3 /var/rocketv2rayHunter/bot.py
7+
WorkingDirectory=/var/rocketv2rayHunter
8+
User=root
9+
Restart=always
10+
RestartSec=10s
11+
12+
[Install]
13+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)