install startup scripts - SOLVED

You have a problem with Salix? Post here and we'll do what we can to help.
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

install startup scripts - SOLVED

Post 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.
Last edited by mimosa on 14. Oct 2010, 11:05, edited 1 time in total.
User avatar
Akuna
Salix Wizard
Posts: 1038
Joined: 14. Jun 2009, 12:25

Re: install startup scripts

Post 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.
Image
What really matters is where you are going, not where you come from.
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: install startup scripts

Post 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.
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: install startup scripts

Post 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.
User avatar
gapan
Salix Wizard
Posts: 6362
Joined: 6. Jun 2009, 17:40

Re: install startup scripts

Post by gapan »

X is not running when rc.local is called. You should run this command only after X is started.
Image
Image
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: install startup scripts

Post 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?
User avatar
gapan
Salix Wizard
Posts: 6362
Joined: 6. Jun 2009, 17:40

Re: install startup scripts

Post by gapan »

The easiest thing to do would be to place it in your autostarted applications list in your DE.
Image
Image
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: install startup scripts

Post 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?
User avatar
gapan
Salix Wizard
Posts: 6362
Joined: 6. Jun 2009, 17:40

Re: install startup scripts

Post 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?
Image
Image
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: install startup scripts

Post 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.
Post Reply