forked from matsuro-hadouken/masternode-telegram-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmn-status-monitor.sh
executable file
·183 lines (137 loc) · 3.27 KB
/
mn-status-monitor.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
rm -f mn-check*
rm -f MasternodeCheck*
clear
echo -e "\e[32mWhat we do ?"
echo -e "\e[39m"
options=("Uninstall" "Install")
select opt in "${options[@]}"
do
case $opt in
"Install")
clear
echo
echo -e "\e[92mOk, let's roll !"
sleep 2
clear
break
;;
"Uninstall")
clear
echo -e "\e[31mWe will remove service from this server."
sleep 1
systemctl stop MasternodeCheck.service
sleep 3
systemctl disable MasternodeCheck.service
sleep 3
killall -I -q MasternodeCheck
sleep 1
rm /usr/local/bin/mn-check*
rm /etc/systemd/system/MasternodeCheck*
systemctl --user daemon-reload
echo -e "\e[39m"
exit
;;
*) ;;
esac
done
# menue end
clear
echo "Please enter your BOT token: "
read TOKEN
clear
echo "Please enter your chat ID here: "
read CHAT_ID
clear
echo
echo -e "\e[31mAre you sure ? "
echo -e "\e[34m"
echo $TOKEN
echo
echo $CHAT_ID
echo -e "\e[39m"
printf "Press any key to continue or 'CTRL+C' to exit "
(tty_state=$(stty -g)
stty -icanon
LC_ALL=C dd bs=1 count=1 >/dev/null 2>&1
stty "$tty_state"
) </dev/tty
clear
echo
echo -e "\e[32mNow lets check Telegram Bot connection."
echo -e "\e[39m"
printf "Press any key to continue or 'CTRL+C' to exit "
(tty_state=$(stty -g)
stty -icanon
LC_ALL=C dd bs=1 count=1 >/dev/null 2>&1
stty "$tty_state"
) </dev/tty
clear
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
curl --silent --output -X POST $URL -d chat_id=$CHAT_ID -d text="PLEASE CONFIRM IN VPS CONSOLE"
clear
echo
echo -e "\e[91mSending message to your channel ..."
sleep 1
clear
echo "Confirm everything setup properly ..."
echo -e "\e[39m"
# confirmation menue
echo -e "\e[32mDid you receive message ? "
echo -e "\e[39m"
options=("Yes" "No")
select opt in "${options[@]}"
do
case $opt in
"Yes")
clear
echo
echo -e "\e[32mOk, cool, continue ..."
sleep 2
echo -e "\e[39m"
clear
break
;;
"No")
clear
echo -e "\e[31mPlease try to obtain right data"
echo -e "\e[31mfor your bot, something is missing"
echo -e "\e[31mor incorrect."
echo
echo -e "\e[95mRefer to GitHub page for more information"
echo -e "\e[39m"
sleep 3
exit
;;
*) ;;
esac
done
# building main script body
echo '#!/bin/bash' > config.tmp
echo >> config.tmp
echo TOKEN=$TOKEN >> config.tmp
echo CHAT_ID=$CHAT_ID >> config.tmp
wget -q https://raw.githubusercontent.com/matsuro-hadouken/masternode-telegram-watcher/master/main.sh
cat config.tmp main.sh > mn-check.sh
rm config.tmp
rm main.sh
# service
chmod a+x mn-check.sh
mv mn-check.sh /usr/local/bin
wget -q https://raw.githubusercontent.com/matsuro-hadouken/masternode-telegram-watcher/master/MasternodeCheck.service
chmod 0644 MasternodeCheck.service
mv MasternodeCheck.service /etc/systemd/system
echo -e "\e[31mStarting service please wait ..."
systemctl enable MasternodeCheck.service
sleep 3
systemctl start MasternodeCheck.service
sleep 3
clear
echo -e "\e[35m"
echo "Checking service status ..."
sleep 3
echo -e "\e[39m"
clear
systemctl status MasternodeCheck.service
sleep 1
exit