added healthchecks
This commit is contained in:
parent
ab99ab97fd
commit
1ff6c3b6d7
8
healthcheck-service
Normal file
8
healthcheck-service
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# /etc/systemd/system/sim800-healthcheck.service
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=SIM800 Healthcheck service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/etc/init.d/sim800c healthcheck
|
||||||
12
healthcheck-timer
Normal file
12
healthcheck-timer
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# /etc/systemd/system/sim800-healthcheck.timer
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=SIM800 healthcheck timer
|
||||||
|
After=sim800.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1min
|
||||||
|
OnUnitActiveSec=1m
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
|
@ -8,7 +8,8 @@ fi
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
apt update
|
apt update
|
||||||
apt install -y ppp curl
|
apt remove -y inetutlis-ping
|
||||||
|
apt install -y ppp curl iputils-ping
|
||||||
|
|
||||||
mkdir -p /etc/ppp/chatscripts
|
mkdir -p /etc/ppp/chatscripts
|
||||||
mkdir -p /etc/ppp/peers
|
mkdir -p /etc/ppp/peers
|
||||||
|
|
@ -19,7 +20,11 @@ curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/chat" > /etc/
|
||||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/peer" > /etc/ppp/peers/sim800c
|
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/peer" > /etc/ppp/peers/sim800c
|
||||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/script" > /etc/init.d/sim800c
|
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/script" > /etc/init.d/sim800c
|
||||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/service" > /etc/systemd/system/sim800.service
|
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/service" > /etc/systemd/system/sim800.service
|
||||||
|
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/healthcheck-service" > /etc/systemd/system/sim800-healthcheck.service
|
||||||
|
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/healthcheck-timer" > /etc/systemd/system/sim800-healthcheck.timer
|
||||||
|
|
||||||
chmod +x /etc/init.d/sim800c
|
chmod +x /etc/init.d/sim800c
|
||||||
systemctl enable sim800
|
systemctl enable sim800
|
||||||
systemctl start sim800
|
systemctl start sim800
|
||||||
|
systemctl enable sim800-healthcheck
|
||||||
|
systemctl start sim800-healthcheck
|
||||||
|
|
|
||||||
28
script
28
script
|
|
@ -4,25 +4,41 @@
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo "AT+CFUN=1,1" > /dev/ttyS3
|
# echo "AT+CFUN=1,1" > /dev/ttyS3
|
||||||
sleep 3
|
# sleep 3
|
||||||
echo "AT+IPR=115200" > /dev/ttyS3
|
# echo "AT+IPR=115200" > /dev/ttyS3
|
||||||
|
# sleep 1
|
||||||
pon sim800c
|
pon sim800c
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
poff sim800c
|
poff sim800c
|
||||||
# sleep 3
|
# sleep 3
|
||||||
# echo "+++" > /dev/ttyS3
|
# echo "+++" > /dev/ttyS3
|
||||||
# sleep 3
|
# sleep 3
|
||||||
echo "AT+CFUN=1,1" > /dev/ttyS3
|
# echo "AT+CFUN=1,1" > /dev/ttyS3
|
||||||
sleep 3
|
# sleep 3
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart|reload)
|
restart|reload)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
sleep 1
|
||||||
$0 start
|
$0 start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
healthcheck)
|
||||||
|
if ! ping -I ppp0 -c 5 -W 5 1.1.1.1 > /dev/null; then
|
||||||
|
echo "Healthcheck failed"
|
||||||
|
systemctl restart sim800
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Healthcheck passed"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|restart}"
|
echo "Usage: $0 {start|stop|restart|healthcheck}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
||||||
6
service
6
service
|
|
@ -6,11 +6,11 @@ After=rc-local.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/run/ppp0.pid
|
# PIDFile=/run/ppp0.pid
|
||||||
ExecStart=/etc/init.d/sim800c start
|
ExecStart=/etc/init.d/sim800c start
|
||||||
ExecStop=/etc/init.d/sim800c stop
|
ExecStop=/etc/init.d/sim800c stop
|
||||||
Restart=on-failure
|
# Restart=on-failure
|
||||||
RestartSec=5s
|
# RestartSec=5s
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user