Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- service shutdown_with_net.service:
- ----------------------------------------------------------------
- [Unit]
- Description=System shutdown script with network
- After=network.target
- Wants=network.target
- [Service]
- Type=oneshot
- Environment=HOME=/storage
- ExecStart=/bin/true
- ExecStop=-/bin/sh -c ". /etc/profile; exec /bin/sh /storage/.config/shutdown_with_net.sh"
- RemainAfterExit=yes
- KillMode=none
- SendSIGKILL=no
- TimeoutSec=5min
- TimeoutStopSec=5min
- [Install]
- WantedBy=multi-user.target
- ----------------------------------------------------------------
- install and enable service:
- cp shutdown_with_net.service /storage/.config/system.d/
- systemctl enable shutdown_with_net.service
- for testing I used
- file autostart.sh:
- ----------------------------------------------------------------
- echo "" >>/storage/ping
- echo -n "autostart " >>/storage/ping
- date "+%H:%M:%S" >>/storage/ping
- (
- sleep 20
- reboot
- )&
- ----------------------------------------------------------------
- and file shutdown_with_net.sh:
- ----------------------------------------------------------------
- echo -n "shutdown start " >>/storage/ping
- date "+%H:%M:%S" >>/storage/ping
- sync
- ping -c 20 -q 10.0.0.1
- echo -n "shutdown done " >>/storage/ping
- date "+%H:%M:%S" >>/storage/ping
- sync
- ----------------------------------------------------------------
- result:
- ----------------------------------------------------------------
- autostart 14:17:47
- shutdown start 14:18:05
- shutdown done 14:18:24
- autostart 14:18:38
- shutdown start 14:18:57
- shutdown done 14:19:16
- .......................
- ----------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement