LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   script execution on halt (https://www.linuxquestions.org/questions/slackware-14/script-execution-on-halt-308747/)

linuxhippy 04-01-2005 04:24 PM

script execution on halt
 
Thanks to masonm, I was able to get my PCMCIA nic configured right when I boot my laptop. It has to do with files not being deleted on shutdown. I wrote a small script that I need to execute on shutdown:

cd /etc/dhcpc
mv -f dhcpcd-eth0.cache dhcpcd-eth0.cache.bak
mv -f dhcpcd-eth0.info dhcpcd-eth0.info.bak
mv -f dhcpcd-eth0.pid dhcpcd-eth0.pid.bak

Now I just need to figure out how to make this script auto-execute when I log out (I tried putting it in /etc/rc.d/rc.6 and it didn't work right).

Any ideas on how to do that?

sigsegv 04-01-2005 04:33 PM

Assuming by "logout" you mean "shutdown", you need to put the script (or more preferably, a symlink to it) in the /etc/rc.d/rc0.d directory as well.

DaHammer 04-01-2005 04:36 PM

Where did you put it in rc.6? Location within the script would be everything, as you'd need to execute the commands after the network is shutdown but prior to the filesystem being unmounted.

linuxhippy 04-01-2005 06:59 PM

I did mean shutdown. I put the following lines after the dhcpcd shutdown in /etc/rc.d/rc.6:

rm /etc/dhcpc/dhcpcd-eth0.cache
rm /etc/dhcpc/dhcpcd-eth0.info
rm /etc/dhcpc/dhcpcd-eth0.pid

This worked for a couple boots-then I couldn't get online again. I commented out the lines and am back to executing the script manually when I successfully get an IP address.

Brian1 04-01-2005 07:09 PM

How about it this way.
create script like this called /etc/rc.d/init.d/dhcp_cleanup
Code:

#!/bin/bash
mv -f /etc/dhcpc/dhcpcd-eth0.cache /etc/dhcpc/dhcpcd-eth0.cache.bak
mv -f /etc/dhcpc/dhcpcd-eth0.info /etc/dhcpc/dhcpcd-eth0.info.bak
mv -f /etc/dhcpc/dhcpcd-eth0.pid /etc/dhcpc/dhcpcd-eth0.pid.bak

Now make it executable by ' chmod +x /etc/rc.d/init.d/dhcp_cleanup '
Now make a softlink to your rc6.d ' ln -s /etc/rc.d/init.d/dhcp_cleanup /etc/rc.d/rc6.d/K50dhcp_cleanup '

If not needed why not delete them instead of renaming.

Brian1
" Google the Linux way @ http://www.google.com/linux "


All times are GMT -5. The time now is 11:04 PM.