0

I am trying to run a script that rsyncs a directory from one linux box to another on shutdown. I thought I had it working but all my tests were on a box connected via a wired connection.

When I tried it on my laptop it failed. I created a debug script that echo's the status from ip into a file and ran that in the service and it showed the carrier is being removed from the wireless interface but not the wired interface so it works over wired no problem but over wifi it fails.

I would like it to work over wireless here is the setup I have been using on my laptop and I have both the wired and wireless interfaces configured.

I have used systemd-analyze plot to make sure the prepowoff service runs late in the boot up so from what i have read the shutdown should occur early in the shutdown sequence.

Here are the files and debug info.

prepowoff.service (in /etc/systemd/system)

[Unit] After=multi-user.target Before=shutdown.service reboot.service halt.service [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/root/bin/debug [Install] WantedBy=multi-user.target 

the debug script (in /root/bin)

#!/bin/bash DATE=$(/bin/date +"%D - %T - %N") WLAN0_STATE=$(/sbin/ip a show wlan0) ETH0_STATE=$(/sbin/ip a show eth0) LOGFILE=/root/bin/log.txt SLEEP=/bin/sleep echo "++++++ START ++++++" > ${LOGFILE} echo ${DATE} >> ${LOGFILE} echo "--------------------" >> ${LOGFILE} echo ${ETH0_STATE} >> ${LOGFILE} echo "--------------------" >> ${LOGFILE} echo ${WLAN0_STATE} >> ${LOGFILE} echo "+++++ END ++++++++" >> ${LOGFILE} 

This is the output of the debug script when I run it once booted the ip info is removed but you can see the status.

++++++ START ++++++ 01/16/16 - 16:50:47 - 145920573 -------------------- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP -------------------- 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP +++++ END ++++++++ 

and here is the output after a reboot showing the wired interface up and wireless one down.

++++++ START ++++++ 01/16/16 - 16:51:10 - 424001117 -------------------- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP -------------------- 3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN +++++ END ++++++++ 

I have tried all sorts enabling the NetworkManager-wait-online.service and going after that but just enabling that service started causing errors. I can't understand why the carrier goes on the wifi as in theory the shutdown of the prepowoff service should happen before anything else.

Any help would be greatly appreciated.

Thanks.

1 Answer 1

0

I managed to get it working with this service file.

[Unit] After=wpa_supplicant.service dbus.service NetworkManager.service Requires=wpa_supplicant.service dbus.service NetworkManager.service [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/root/bin/prepowoff [Install] WantedBy=multi-user.target 

wpa supplicant and dbus were taking down the wireless card even though Network Manager was still running.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.