Page 1 of 2

install startup scripts - SOLVED

Posted: 13. Oct 2010, 12:48
by mimosa
This is more a request for some kind help than a problem as such. My research suggested that putting a line in /etc/rc.d/rc.local could be a good way to get Salix to run a script on every boot, but it didn't work:

Code: Select all

bash: rc.local: command not found
root[rc.d]# cat rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

# swap functions of delete and backspace keys
/etc/init.d/swap_delete_bksp.sh
root[rc.d]# chmod +x rc.local
root[rc.d]# rc.local
bash: rc.local: command not found
The little one-line script itself works perfectly, helping me get along with a keyboard missing a backspace key. Of course, I wouldn't expect to have to do anything to rc.local if it does indeed run during boot. But I was just testing.

I imagine I haven't been going about this the right way - and would be very grateful for any pointers. It'd be useful for all sorts of things to know how to add automatic actions at boot, not just my dodgy keyboard.

Btw I read the help file in /etc/init.d, so I know that isn't the right place to put this sort of thing, but that surely isn't important for the problem at hand.

Re: install startup scripts

Posted: 13. Oct 2010, 13:40
by Akuna
Full path is

Code: Select all

/etc/rc.d/rc.local
or if you are in /etc/rc.d

Code: Select all

./rc.local
But it is meant to be executed without user's interaction at boot time.

Re: install startup scripts

Posted: 13. Oct 2010, 14:22
by thenktor
What's the content of this script and where did you get it: /etc/init.d/swap_delete_bksp.sh

You probably can move it to /etc/rc.d/rc.swap_delete_bksp and you won't need rc.local then.

Re: install startup scripts

Posted: 13. Oct 2010, 19:59
by mimosa
@ Akuna

It seems I was calling it the wrong way (*missing ./); I've just done it exactly as you did, and it worked. But it still doesn't have any effect during boot, which I was hoping it would - thus automating my keyboard workaround.

@ Thenktor

I wrote the script myself :ugeek:

But seriously, it isn't very long:

root[tim]# cat /etc/init.d/swap_delete_bksp.sh
xmodmap -e "keysym BackSpace = Delete" -e "keysym Delete = BackSpace"
root[tim]#

and it definitely works if called manually. What I am trying to understand is how to get Linux to run things the user tells it to automatically at boot. Since my original post, I have also tried putting the same script within the /etc/rc.d/ directory, renaming it rc.foo, as Thenktor suggests - some of my research also suggested that any script in that directory and with that prefix should just run automatically at boot. But it seems not.

Some of my reading referred to "installing" user-authored scripts, but that was for Ubuntu. Moreover, the commented lines in rc.local certainly make it look as though adding lines to it is one way to go.

Re: install startup scripts

Posted: 13. Oct 2010, 20:32
by gapan
X is not running when rc.local is called. You should run this command only after X is started.

Re: install startup scripts

Posted: 13. Oct 2010, 21:08
by mimosa
Thanks Gapan, that explains why it didn't work even though it works. Is there a place I can put things to run automatically after X starts?

Re: install startup scripts

Posted: 13. Oct 2010, 21:17
by gapan
The easiest thing to do would be to place it in your autostarted applications list in your DE.

Re: install startup scripts

Posted: 14. Oct 2010, 09:08
by mimosa
I tried to do so like this:

Code: Select all

root[tim]# mv /etc/init.d/swap_delete_bksp.sh /home/tim/.config/autostart
but it still didn't work, even when I chmod +x'd the file just in case.

Should I actually have put it somewhere else?

Re: install startup scripts

Posted: 14. Oct 2010, 09:49
by gapan
You need to put a .desktop file for you application in there, not the script itself. Why don't you use the Autostarted applications entry from the settings menu?

Re: install startup scripts

Posted: 14. Oct 2010, 11:04
by mimosa
Thank you Gapan - that did it, of course. Thank you also Akuna and Thenktor.

For anyone reading this who doesn't know, Autostart applications is inside Session and Startup under Settings - as one might guess.