| ECS Home Automation and Security Archives |
| Subject: From: Date: | Re: [ecs] Linux login cmds Ingo Pakleppa 24 Oct 2003 00:16:17 -0700 |
It sounds like the first few steps are one-time installation tasks, and then you start ECS. If you want to really start something automatically in the Linux world, the preferred solution is to make it a daemon. It's not all that difficult to do. Daemons are controlled with a script; in your case, it would be /etc/rc.d/init.d/ecs To make it start automatically, you'd simply put a link to it into /etc/rc.d/rc3.d and /etc/rc.d/rc5.d (the number corresponds to the runlevel. The links in rc3.d will be executed for text mode, runlevel 3. The links in rc5.d will be executed if you boot into X, runlevel 5). The name of the link must start with S, followed by two digits. So it should be /ecs/rc.d/rc3.d/S95ecs To start and stop ecs manually, you would type /etc/rc.d/init.d/ecs stop /etc/rc.d/init.d/ecs start (and you have to write the script ecs so that it understands the start and stop arguments. This is mandatory for the mechanism to work. Most scripts also understand restart, and some understand a couple additional parameters). This is true for RedHat; there are slight variations for other distributions, but all are very similar. The number determines in which order the various daemons are started. ECS basically just needs to detach itself from the terminal (I haven't done this myself, but check out the daemon() function - it will redirect stdin, stdout and stderr to /dev/null and detach your app from the terminal). Daemons are started just like any other applications, from the above-mentioned script. Traditionally, you cause them to terminate with a signal (I believe SIGTERM). Try "man signal" for the basics. One difference to what you were suggesting: ECS would be launched BEFORE the user "knoppix" logs on. For the installation part, I would put that into /home/knoppix/.bash_profile because otherwise, all users of the system would end up executing these commands on logon. On Thu, 2003-10-23 at 12:04, Mark Gilmore wrote: > Hi Ingo, > When Knoppix *automatically* logs the "knoppix" user in at bootup, > my commands will: > Create /home/knoppix/ecs, etc > Copy all ecs files to same > Set permissions as appropriate for all of the above > Start ecs > These command will be executed *only* if /home/knoppix/ecs does not already > exist. > Right now, they are in /etc/profile. > Sound OK ? > Thanks, > > At 01:52 AM 10/23/2003 -0700, you wrote: > > >Do you want this to happen only for one particular user, or for all > >users? It may also help if you said exactly what kind of commands you > >want executed. > > > >Regardless, it depends on how the user logs in. If the user logs in and > >gets a bash shell, then his ~/.bashrc or ~/.bash_profile file would be > >the appropriate place (or /etc/bashrc or /etc/profile if you want to > >affect all users). > > > >Personally, I have all of the above. For instance, I put ssh-agent into > >/etc/X11/xinit/xinitrc and xdm/Xsession and I set a couple environment > >variables in ~/bash_profile (note that those variables won't be > >available to X!) > > > >If the user logs into X, then it goes somewhere into /etc/X11. Exactly > >where depends on whether you are using KDE, Gnome, or something else. > > > >Linux has a lot of options. Unfortunately, at times it also means that > >what you want may vary from one system to the next. > > > >On Wed, 2003-10-22 at 16:01, Mark Gilmore wrote: > > > If I want Linux to execute some commands after someone logs in, > > > what file do I place them in ? > > > Thanks, > > > > > > Mark Gilmore > > > http://OmnipotenceSoftware.com > > > > > > ______________________________________________________________________ > > > > > > --- > > > Outgoing mail is certified Virus Free. > > > Checked by AVG anti-virus system (http://www.grisoft.com). > > > Version: 6.0.528 / Virus Database: 324 - Release Date: 10/16/2003 > >-- > >Ingo Pakleppa <ipakleppa@kkeane.com> > > > > > > > >--- > >Incoming mail is certified Virus Free. > >Checked by AVG anti-virus system (http://www.grisoft.com). > >Version: 6.0.528 / Virus Database: 324 - Release Date: 10/16/2003 > > Mark Gilmore > http://OmnipotenceSoftware.com > > ______________________________________________________________________ > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.528 / Virus Database: 324 - Release Date: 10/16/2003