Thanks ehartman, I have created a file /lib/systemd/system/my-service.service like this:
Code:
[Unit]
Description=My Service
After=network-online.target
[Service]
Type=oneshot
ExecStart=/etc/init.d/my-service start
RemainAfterExit=true
ExecStop=/etc/init.d/my-service stop
[Install]
WantedBy=network-online.target
The service start and stops correctly but, inside the shell script I call (ping
www.google.com) for cheching network, and I obtain the next output:
Code:
PING www.google.com (172.217.17.4) 56(84) bytes of data.
64 bytes from mad07s09-in-f4.1e100.net (172.217.17.4): icmp_seq=1 ttl=53 time=11 .0 ms
64 bytes from mad07s09-in-f4.1e100.net (172.217.17.4): icmp_seq=2 ttl=53 time=10 .0 ms
64 bytes from mad07s09-in-f4.1e100.net (172.217.17.4): icmp_seq=3 ttl=53 time=69 .9 ms
ping: sendmsg: The network is inaccessible
ping: sendmsg: The network is inaccessible
ping: sendmsg: The network is inaccessible
ping: sendmsg: The network is inaccessible
ping: sendmsg: The network is inaccessible
In the begining of execution of the service the network is up but in the middle of the exetion the networg goes down.
How could I stop the rest of the services until my-service ends?
Thanks in advance.