-
Notifications
You must be signed in to change notification settings - Fork 1
/
health.sh
32 lines (24 loc) · 956 Bytes
/
health.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
#!/bin/bash
# Please define an http proxy on xui pannel for this reason
hstatus=$(curl 'https://www.whatsapp.com' --proxy "http://{user}:{password}@{host}:{port}" --max-time 15 -s -o /dev/null -w "%{http_code}")
echo $hstatus
start_time=$(date +%s.%N)
end_time=$(date +%s.%N)
duration=$(echo "$end_time - $start_time" | bc)
echo "Duration: $duration seconds to fetch"
if [ "$hstatus" -eq 200 ]; then
echo "Whatsapp web fetched successfully";
else
echo "Service is down or has been censored";
echo "Going to restart frpc*";
systemctl restart frpc*;
echo "Going to restart stunnel";
systemctl restart stunnel*;
echo "Going to restart x-ui.service";
systemctl restart x-ui.service;
echo "Going to restart ns2.ns2ns2.com frps, x-ui, stunnel services";
ssh {user}@{host} "sudo systemctl restart frps.service"
ssh {user}@{host} "sudo systemctl restart x-ui.service"
ssh {user}@{host} "sudo systemctl restart stunnel4.service"
echo "Done"
fi