-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathstart
More file actions
104 lines (83 loc) · 2.08 KB
/
Copy pathstart
File metadata and controls
104 lines (83 loc) · 2.08 KB
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
#!/bin/bash
while true; do
read -p "Masukkan bot token: " bot_token
if [[ -n "$bot_token" ]]; then
break
else
echo "Bot token tidak boleh kosong. Silakan coba lagi."
fi
done
while true; do
read -p "Masukkan bot admin ID: " bot_admin_id
if [[ "$bot_admin_id" =~ ^[0-9]+$ ]]; then
break
else
echo "Bot admin ID harus berupa angka. Silakan coba lagi."
fi
done
while true; do
read -p "Masukkan nama store: " nama_store
if [[ -n "$nama_store" ]]; then
break
else
echo "Nama store tidak boleh kosong. Silakan coba lagi."
fi
done
apt update -y
if ! command -v python3 &> /dev/null
then
apt install python3 -y
else
echo "python3 sudah terinstal"
fi
if ! command -v pip3 &> /dev/null
then
apt install python3-pip -y
else
echo "pip3 sudah terinstal"
fi
if [ ! -d "/root/DigitalOcean-TeleBot" ]; then
git clone https://github.com/FighterTunnel/DigitalOcean-TeleBot.git
else
echo "Repository sudah ada"
fi
if [ -f "/root/DigitalOcean-TeleBot/requirements.txt" ]; then
pip3 install -r /root/DigitalOcean-TeleBot/requirements.txt
else
echo "File requirements.txt tidak ditemukan"
fi
SERVICE_NAME="do"
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
if [ -f "/root/DigitalOcean-TeleBot/config.json" ]; then
rm /root/DigitalOcean-TeleBot/config.json
fi
cat <<EOT > /root/DigitalOcean-TeleBot/config.json
{
"BOT": {
"NAME": "$nama_store",
"TOKEN": "$bot_token",
"ADMINS": [$bot_admin_id]
}
}
EOT
if [ ! -f "$SERVICE_FILE" ]; then
echo "[Unit]
Description=My Python Service
After=network.target
[Service]
ExecStart=/usr/bin/python3 /root/DigitalOcean-TeleBot/main.py
WorkingDirectory=/root/DigitalOcean-TeleBot
StandardOutput=inherit
StandardError=inherit
Restart=always
User=root
[Install]
WantedBy=multi-user.target" > $SERVICE_FILE
systemctl daemon-reload
systemctl enable $SERVICE_NAME
systemctl start $SERVICE_NAME
systemctl restart $SERVICE_NAME
else
echo "Service $SERVICE_NAME sudah ada"
fi
echo "Service $SERVICE_NAME telah diinstal"