fixed systemd unit issues

This commit is contained in:
justmarvinn 2025-04-20 21:29:54 +02:00
parent 14dd229abd
commit 43a35283db
3 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@
# force run from root user
if [[ $EUID -ne 0 ]]; then
exec sudo "$0" "$@"
exec sudo "$0" "$@"
fi
set -e
@ -17,9 +17,9 @@ mkdir -p /etc/systemd/system
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/chat" > /etc/ppp/chatscripts/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.sh
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/service" > /etc/systemd/system/sim800c.service
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
chmod +x /etc/init.d/sim800c
systemctl enable sim800c
systemctl start sim800c
systemctl enable sim800
systemctl start sim800

4
script
View File

@ -1,10 +1,11 @@
#!/bin/bash
# /etc/init.d/sim800c.sh
# /etc/init.d/sim800c
case "$1" in
start)
echo "AT+CFUN=1,1" > /dev/ttyS3
sleep 3
echo "AT+IPR=115200" > /dev/ttyS3
pon sim800c
;;
@ -14,6 +15,7 @@ stop)
# echo "+++" > /dev/ttyS3
# sleep 3
echo "AT+CFUN=1,1" > /dev/ttyS3
sleep 3
;;
restart|reload)
$0 stop

View File

@ -1,4 +1,4 @@
# /etc/systemd/system/sim800c.service
# /etc/systemd/system/sim800.service
[Unit]
Description=SIM800C PPP Connection
@ -7,8 +7,8 @@ After=rc-local.service
[Service]
Type=forking
PIDFile=/run/ppp0.pid
ExecStart=/etc/init.d/sim800c.sh start
ExecStop=/etc/init.d/sim800c.sh stop
ExecStart=/etc/init.d/sim800c start
ExecStop=/etc/init.d/sim800c stop
Restart=on-failure
RestartSec=5s