Newbie questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to Antonio Orlando <ant.o at libero.it>:
> > * How can you make an application (eg: claws-mail) start
> > automatically at power-up? (I'm happy working at the command
> > prompt as root.)
> 
> I don't know if it's the right way to do this, but I can successfully  
> start an application at startup on my Nokia 770 (N800 might differ) after  
> doing these steps:
> 
> 1) experiment in terminal to find the exact command with absolute path you  
> can use to launch the desired app;
>
> 2) become root
> 

This is good so far. But one thing to remember is that any command run
during startup is going to run as root, rather than user. I've no
idea if clawsmail cares, but you can fix this by prefixing the command
with 'su user -l -c', for example:

su user -l -c  "/usr/bin/whateverclawsmailis --options --if --necessary"


> 3) modify the file "/etc/osso-af-init/real-af-startup" inserting a new  
> line after the n. 91, where it says "rm -f /tmp/im_disable_tools_menu"
> 
> 4) write in the new line the command tested at step 1)

Urr. Among other issues, this stands a fair chance of being overwritten
on upgrades.

A more standard unixy way to do this is to add a seperate startup file.

1. Create the file "/etc/init.d/clawsmail". While the following is
not really a complete init.d script, I think it's sufficient for your 
purposes:

====================================
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH
set -e
case "$1" in
	start)
		su user - -c "/usr/bin/clawsmail --whatever"
		;;
	*)
		echo "only starts clawsmail"
		;;
esac
exit 0
====================================

2. Make the file executable:

	chmod a+x /etc/init.d/clawsmail

2a. Test the script (from an xterm on the device!):

	/etc/init.d/clawsmail start

3. Make the file callable during startup:

	update-rc.d clawsmail defaults 99 01

This last command creates links in the various /etc/rc[1-6].d
directories; the '99' makes sure it's run near the end of startup.

To stop the startup, just remove the links:

	update-rc.d -f clawsmail remove

The advantages of this over the original solution:

1. You're not editing a critical system file.

2. You're changes won't be overwritten. (Well, maybe not during a flash.
Does the "backup/restore" procedure save the contents of /etc/init.d and
the links?)

3. This is where every experienced Linux person will expect to find
startup stuff.

Regards,
Steve


-- 
Steve Greenland
    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world.       -- seen on the net



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Big List of Linux Books]    

  Powered by Linux