PDA

View Full Version : Adding a script to the shutdown process



Zotova
September 29th, 2005, 04:23 PM
Sorry if this is in the wrong section - it seemed the most relevant section to my question.

Anyhow, I have a laptop which I use in various places, some in which I do not want to have the volume very high. But I constantly forget to turn the volume down when I quit Ubuntu. So I have written a script which basically mutes the volume when it is run.

My question is basically what file should I add my script too or is there a program which will allow me to add custom startup/shutdown commands. (Similar to a Windows style startup folder)

adwait
September 29th, 2005, 04:54 PM
I dunno about running scripts on shutdown, but if you want to run it on start up, add it to /etc/init.d

the use


sudo rcconf


Make sure you have set the execute permissions on that script.
Find your script name and check the box next to it (using space bar).

sas
October 23rd, 2005, 03:12 PM
Put your script in /etc/rc.d/rc0.d/ and call it KXXturnvoldown

where turnvoldown is your script name and xx is a number.

When the system is shutdown (aka init 0) it goes into /etc/rc.id/rc0.d/ and executes all scripts that have a name starting with K in the order of the numbers in the script names.

To have the script run on startup add it to /etc/rc.d/rc5.d/ and call it Sxxturnvoldown

S is for start script, K is for kill script.

LordHunter317
October 23rd, 2005, 05:14 PM
To have the script run on startup add it to /etc/rc.d/rc5.d/ and call it SxxturnvoldownThis isn't redhat, default startup level is 2.

And you need to link your shutdown script to runlevel 6 as well, to have it occur on reboot (not poweroff, they're distinct).

sas
October 23rd, 2005, 09:14 PM
So it is, I never noticed that.

Surely having the script run on reboot is pointless? unless he/she sets the computer to reboot whilst running from a volume place to a mute one or something.

I just set the volume control to mute and saved settings on logout, now I turn it up if I need it, but if not, it's ready muted.

majikstreet
October 24th, 2005, 12:34 AM
I dunno about running scripts on shutdown, but if you want to run it on start up, add it to /etc/init.d

the use


sudo rcconf


Make sure you have set the execute permissions on that script.
Find your script name and check the box next to it (using space bar).
I was just randomly trying that, and I noticed that it isn't installed on my system. Apt-get it first :P