I have a script on the PI to shutdown my NAS "shutdown_nas.sh". I have created that script in /etc/init.d according to the instructions in /etc/init.d/README

It is symlinked in /etc/rc0.d/K01NAS_shutdown.sh

It works fine when I call:

sudo service shutdown_nas.sh stop

It also works fine when I halt the PI when I'm on ethernet (eth0).

It doesn't work on WIFI only, it seems like wlan is down before the needed request is done.

  • I think you need a higher runlevel. Try /etc/rc2.d/K01NAS_shutdown.sh, or /etc/rc3.d/K01NAS_shutdown.sh – Gerben May 21 '14 at 11:10
  • I fail to see that. It should run on shutdown, rc0.d. en.wikipedia.org/wiki/Runlevels – Janghou May 21 '14 at 12:30
  • I don't really understand runlevels that well. Reading a bit more, I think you're right. Is K01... the first file in the rc2.d directory? Is there a K00.. that messes thins up? – Gerben May 21 '14 at 14:21
  • 1
    No, and the script does work (mutatis mutandis) on a Ubuntu 14.04 laptop, so it must be a RPI thing. Maybe because the dongle is on a USB-hub – Janghou May 22 '14 at 18:56

Change the sequence number of your service so it is called before the wifi service.

man update-rc.d
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.