-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
68 lines (61 loc) · 1.83 KB
/
install.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
#!/bin/bash
# Compatible with Ubuntu ≥ 18 || Debian ≥ 10
magenta="\e[35m"
b_yellow="\e[93m"
cyan="\e[36m"
red="\e[31m"
green="\e[32m"
endl="\e[0m"
uninstall() {
if [ -f "/etc/systemd/system/tlgidbot.service" ]; then
systemctl stop tlgidbot.service
systemctl disable tlgidbot.service
rm -f /etc/systemd/system/tlgidbot.service
rm -f $HOME/.tlgidbot.py
systemctl daemon-reload
fi
}
install() {
apt install python3 python3-pip -y
python_path=$(which python3)
pip3 install python-telegram-bot==13.1
if [ -f "/etc/systemd/system/tlgidbot.service" ]; then
uninstall
fi
curl https://raw.githubusercontent.com/jalalsaberi/TLG-ID-BOT/main/tlgidbot.py > $HOME/.tlgidbot.py
chmod +x $HOME/.tlgidbot.py
clear
echo -en "${magenta}Enter your Telegram Bot Token: ${endl}" && read token
sed -i "s/TOKEN = ''/TOKEN = '$token'/" $HOME/.tlgidbot.py
cat > "/etc/systemd/system/tlgidbot.service" << EOF
[Unit]
Description=Telegram ID Bot
[Service]
ExecStart=$python_path $HOME/.tlgidbot.py
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable tlgidbot.service > /dev/null
systemctl start tlgidbot.service > /dev/null
systemctl status tlgidbot.service
}
main() {
clear
echo -e "${b_yellow}Telegram ID Bot${endl}\n"
echo -e "${cyan}1. Install${endl}\n${cyan}2. Uninstall${endl}\n"
echo -en "${magenta}Choose: ${endl}" && read option
if [[ $option == 1 ]]; then
install
echo -e "\n${green}Telegram ID Bot Installed Successfully${endl}\n"
elif [[ $option == 2 ]]; then
uninstall
echo -e "\n${green}Telegram ID Bot Uninstalled Successfully${endl}\n"
else
echo -en "\n${red}Wrong Option!!! Choose again.${endl}\n"
sleep 1.5
main
fi
}
main