|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Here's the situation; I have a program that needs to run at system
startup, but there are a few issues with that. First, it must be run with a certain directory as the working directory. Second it must be run as the user 'Fox' The information I've been able to find would end up with the program running as root and not from the right directory. I'm used to Macs and have no idea what I'm doing here, but I'm learning! Thanks. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Aug 20, 2007, at 2:15 PM, Neil Watson wrote: > The scripts in /etc/init.d are working examples of what you are trying > to do. > Yea I was directed there before, but those are what I was talking about where they don't do the two things I need them to do. > -- > Neil Watson | Debian Linux > System Administrator | Uptime 2 days > http://watson-wilson.ca > -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
The scripts in /etc/init.d are working examples of what you are trying to do.
-- Neil Watson | Debian Linux System Administrator | Uptime 2 days http://watson-wilson.ca -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Mon, 20 Aug 2007, ArcticFox wrote:
> > On Aug 20, 2007, at 2:15 PM, Neil Watson wrote: > >> The scripts in /etc/init.d are working examples of what you are trying to >> do. >> > Yea I was directed there before, but those are what I was talking about where > they don't do the two things I need them to do. what about something like this: #!/bin/sh cd /to/your/dir /bin/su -c "./yourapp" user-to-run-as -+- 8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Techno. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Create a script in /etc/init.d and make a symbolic link to it in the rc
runlevel directory that corresponds to your runlevel (or whatever runlevel you want the script to run). For example, the /etc/init.d/foo.sh may be: #!/bin/bash cd /foo /foo/make_something.sh If you want this script to run in runlevel 2, then you can: ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo In the other hand, at any moment you can now the runlevel in what you are just typing: who -r Have a look at /etc/init.d scripts, they are self explanatory. Also, have a look at "man init" Regards On Monday 20 August 2007 21:00, ArcticFox wrote: > Here's the situation; I have a program that needs to run at system > startup, but there are a few issues with that. First, it must be run > with a certain directory as the working directory. Second it must be > run as the user 'Fox' > > The information I've been able to find would end up with the program > running as root and not from the right directory. I'm used to Macs and > have no idea what I'm doing here, but I'm learning! > > Thanks. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Mon, Aug 20, 2007 at 02:17:24PM -0500, ArcticFox wrote:
>On Aug 20, 2007, at 2:15 PM, Neil Watson wrote: > >>The scripts in /etc/init.d are working examples of what you are trying >>to do. >> >Yea I was directed there before, but those are what I was talking about >where they don't do the two things I need them to do. /etc/init.d/skeleton man start-stop-daemon -- Neil Watson | Debian Linux System Administrator | Uptime 2 days http://watson-wilson.ca -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Mon, 2007-08-20 at 21:20 +0200, srgqwerty wrote:
> Create a script in /etc/init.d and make a symbolic link to it in the > rc runlevel directory that corresponds to your runlevel invoke-rc.d is the tool to do that. Anyway, you did not indicate enough how to run the things as a particular user. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
* srgqwerty <srgqwerty@gmail.com> [2007 Aug 20 14:25 -0500]:
> Create a script in /etc/init.d and make a symbolic link to it in the rc > runlevel directory that corresponds to your runlevel (or whatever runlevel > you want the script to run). > > For example, the /etc/init.d/foo.sh may be: > #!/bin/bash > cd /foo > /foo/make_something.sh > > If you want this script to run in runlevel 2, then you can: > ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo I like to create my local init scripts in /usr/local/etc/init.d and symlink from there. It prevents, however unlikely, a conflict with the Debian scripts. It also makes it quite easy to find that local script that was created many moons ago. - Nate >> -- Wireless | Amateur Radio Station N0NB | Successfully Microsoft Amateur radio exams; ham radio; Linux info @ | free since January 1998. http://www.qsl.net/n0nb/ | "Debian, the choice of My Kawasaki KZ-650 SR @ | a GNU generation!" http://www.networksplus.net/n0nb/ | http://www.debian.org -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
On 08/20/2007 03:00 PM, ArcticFox wrote:
> Here's the situation; I have a program that needs to run at system > startup, but there are a few issues with that. First, it must be run > with a certain directory as the working directory. Second it must be run > as the user 'Fox' I'm no expert, but how about using cron and crontab for user fox? Use "@reboot' for the start time. man cron man crontab Good luck! Ralph -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Tue, Aug 21, 2007 at 08:20:04AM -0400, Ralph Katz wrote:
> On 08/20/2007 03:00 PM, ArcticFox wrote: > > Here's the situation; I have a program that needs to run at system > > startup, but there are a few issues with that. First, it must be run > > with a certain directory as the working directory. Second it must be run > > as the user 'Fox' man start-stop-daemon specificically: -c Change to this username/uid before starting the process -d Chdir to path before starting the process. Doug. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
On Aug 20, 2007, at 2:20 PM, srgqwerty wrote: > Create a script in /etc/init.d and make a symbolic link to it in the rc > runlevel directory that corresponds to your runlevel (or whatever > runlevel > you want the script to run). So just chuck it in anywhere? Does it matter who owns the file? Should it be the user? root? > > For example, the /etc/init.d/foo.sh may be: > #!/bin/bash > cd /foo > /foo/make_something.sh > > If you want this script to run in runlevel 2, then you can: > ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo So I'd make the file, put it somewhere in /etc/init.d then symlink it to /etc/rc2.d ? Seems kinda... random to me. > > In the other hand, at any moment you can now the runlevel in what you > are just > typing: > who -r > > Have a look at /etc/init.d scripts, they are self explanatory. There's no directory in /etc/init.d called scripts. I know nothing about shell scripting and many of you seem to assume that I know what I'm doing here. I'm a Mac guy, command lines still scare me. > Also, have a look at "man init" > > Regards > > On Monday 20 August 2007 21:00, ArcticFox wrote: >> Here's the situation; I have a program that needs to run at system >> startup, but there are a few issues with that. First, it must be run >> with a certain directory as the working directory. Second it must be >> run as the user 'Fox' >> >> The information I've been able to find would end up with the program >> running as root and not from the right directory. I'm used to Macs and >> have no idea what I'm doing here, but I'm learning! >> >> Thanks. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
On Tue, 21 Aug 2007, ArcticFox wrote:
> > On Aug 20, 2007, at 2:20 PM, srgqwerty wrote: > >> Create a script in /etc/init.d and make a symbolic link to it in the rc >> runlevel directory that corresponds to your runlevel (or whatever runlevel >> you want the script to run). > > So just chuck it in anywhere? Does it matter who owns the file? Should it be > the user? root? >> >> For example, the /etc/init.d/foo.sh may be: >> #!/bin/bash >> cd /foo >> /foo/make_something.sh >> >> If you want this script to run in runlevel 2, then you can: >> ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo > > So I'd make the file, put it somewhere in /etc/init.d then symlink it to > /etc/rc2.d ? Seems kinda... random to me. >> >> In the other hand, at any moment you can now the runlevel in what you are >> just >> typing: >> who -r >> >> Have a look at /etc/init.d scripts, they are self explanatory. > > There's no directory in /etc/init.d called scripts. I know nothing about > shell scripting and many of you seem to assume that I know what I'm doing > here. I'm a Mac guy, command lines still scare me. > >> Also, have a look at "man init" >> >> Regards /etc/init.d/ is where all of the startup scripts should live. /etc/rc2.d for example, holds all the scripts that get started up in run level 2, which is the defult run level for debian, so it may seem random, but really its not. It's just easier to have the scripts in /etc/init.d/ and link them to all the differnt run levels if you need them. The S99 , says start and the init process executes each script in a numerical order, if you look in /etc/rc2.d you will see a which order things get started. Usually for user added stuff 99 is good. So first thing you need to do, it make the script so that it runs the way you want. You also have to remember that scripts get ran as root at start up too. But you need to have your command ran as fox right? so: su -c "command" fox that will run the command you want as fox, through su. for example: #!/bin/sh PATH=/bin:/usr/bin cd /usr/local/myapp/ su -c "./myappp " fox that, if ran throught the init process would result the script cd'ing into the directory /usr/local/myapp/ and running myapp as fox.. once you have your script working the way you want it to, place it in /etc/init.d then link it as above. Also, take a look at /etc/rc2.d/README hth Jeff -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
![]() |
| Outils de la discussion | |
|
|