Debian This forum is for the discussion of Debian Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
09-02-2004, 09:08 PM
|
#1
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Rep:
|
Script to run at boot
I've been attempting to get a script to run at boot. I have followed the instructions here to create an /etc/init.d/local file:
http://www.desktop-linux.net/debian-rclocal.htm
The script "seems" to run because on shutdown/reboot init attempts to shut down the daemon which is supposed to be started by the script. The daemon itself is not started, however.
Here is the command line for the script (it starts my UPS monitor daemon):
SentryII daemon -c ./SentryII.ini
The problem is the script must be run by root from in /usr/local/sbin
Any thoughts or ideas on how I can write this into a script to run???
Thanks in advance for your help!
|
|
|
09-02-2004, 09:55 PM
|
#2
|
Member
Registered: Aug 2004
Location: San Diego
Distribution: Slackware
Posts: 303
Rep:
|
would a symlink work?
|
|
|
09-03-2004, 12:51 AM
|
#3
|
Member
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519
Rep:
|
Hi,
Try put a "cd /usr/local/sbin" before the line which calls the daemon in the script.
|
|
|
09-03-2004, 08:02 AM
|
#4
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by osvaldomarques
Hi,
Try put a "cd /usr/local/sbin" before the line which calls the daemon in the script.
|
That doesn't work either. I probably should have posted the entire script:
#! /bin/sh
cd /usr/local/sbin/
SentryII daemon -c ./SentryII.ini
cd
I had assumed this would work since it works from the command line but for some reason it does not work from the script.
Thanks for the thought!
Ideas???
|
|
|
09-03-2004, 08:03 AM
|
#5
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by redjokerx
would a symlink work?
|
A symlink "where" and to "what"?
|
|
|
09-03-2004, 08:25 AM
|
#6
|
Member
Registered: Feb 2004
Location: Mooresville NC
Distribution: CentOS 4,Free BSD,
Posts: 358
Rep:
|
Take the (cd) out of it and it will run.
You need to study on writing scripts. I'm not geat so I cannot help, but I know that you do not need (cd)
|
|
|
09-03-2004, 10:09 AM
|
#7
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by phatboyz
Take the (cd) out of it and it will run.
... but I know that you do not need (cd)
|
Tanking the cd (or both of them out) did not fix it. Taking the cd out of the first line would cause /usr/local/sbin to be seen as a command would it not?
The "local" script itself is:
#! /bin/sh
cd /usr/local/sbin
SentryII daemon -c ./SentryII.ini
If I boot, log on as root and run:
/etc/init.d/local
The daemon starts fine:
Debian:/home/rscarroll# /etc/init.d/local
Debian:/home/rscarroll# ps aux | grep SentryII
root 4739 0.0 0.1 3268 1848 ? Ss 09:53 0:00 SentryII daemon -c ./SentryII.ini
root 4742 0.0 0.0 1576 472 pts/0 S+ 09:54 0:00 grep SentryII
Debian:/home/rscarroll# pidof SentryII
4739
I think the issue is having to be logged on as root for it to run... I may be wrong.
Thoughts or ideas? It's a pain having to remember to start this manually! (Yes, I could run it as a cron job every minute and create a script to suit but that's fixing the symptom, not the problem!)
|
|
|
09-03-2004, 10:38 AM
|
#8
|
Senior Member
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170
|
Quote:
Originally posted by robbow52
Tanking the cd (or both of them out) did not fix it. Taking the cd out of the first line would cause /usr/local/sbin to be seen as a command would it not?
The "local" script itself is:
#! /bin/sh
cd /usr/local/sbin
SentryII daemon -c ./SentryII.ini
If I boot, log on as root and run:
/etc/init.d/local
The daemon starts fine:
Debian:/home/rscarroll# /etc/init.d/local
Debian:/home/rscarroll# ps aux | grep SentryII
root 4739 0.0 0.1 3268 1848 ? Ss 09:53 0:00 SentryII daemon -c ./SentryII.ini
root 4742 0.0 0.0 1576 472 pts/0 S+ 09:54 0:00 grep SentryII
Debian:/home/rscarroll# pidof SentryII
4739
I think the issue is having to be logged on as root for it to run... I may be wrong.
Thoughts or ideas? It's a pain having to remember to start this manually! (Yes, I could run it as a cron job every minute and create a script to suit but that's fixing the symptom, not the problem!)
|
Try update-rc.d local defaults to put links to the file in the startup/shutdown runlevels and see if that helps.
|
|
|
09-03-2004, 10:44 AM
|
#9
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
You should check if update-rc.d has made the proper symlink from /etc/init.d/local to /etc/rc2.d/. Also check dmesg and /var/log/ for error messages. If it's something like /etc/rc2.d/S80local, changing it to start a bit later (like S99local) may help.
I might be wrong, but if you can execute your script from the command line, I think that the script itself is OK. Nevertheless, double-check that /etc/init.d/local is executable (chmod 755 /etc/init.d/local).
|
|
|
09-03-2004, 12:34 PM
|
#10
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by Dead Parrot
You should check if update-rc.d has made the proper symlink from /etc/init.d/local to /etc/rc2.d/. Also check dmesg and /var/log/ for error messages. If it's something like /etc/rc2.d/S80local, changing it to start a bit later (like S99local) may help.
I might be wrong, but if you can execute your script from the command line, I think that the script itself is OK. Nevertheless, double-check that /etc/init.d/local is executable (chmod 755 /etc/init.d/local).
|
The symlinks were created (This is the link for rc2.d...Similar links for each runlevel).
lrwxrwxrwx 1 root root 15 Sep 2 10:01 S90local -> ../init.d/local
(When I updated init I ran update-rc.d local 90)
Here is the output of ls -la for local:
-rwxr-xr-x 1 root root 65 Sep 3 09:49 /etc/init.d/local
I will remove the symlinks and try "update-rc.d /etc/init.d/local 99" and see what happens!
Thanks for the ideas!
|
|
|
09-03-2004, 12:53 PM
|
#11
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
First remove all existing symlinks for the "local" script:
# update-rc.d -f local remove
Then add a new symlink S99local to /etc/rc2.d/ (and K99local to appropriate runlevels to stop the service in system shutdown):
# update-rc.d local start 99 2 . stop 99 0 1 6 .
Or, If you want to start the "local" script in any runlevel, do this instead:
# update-rc.d local start 99 2 3 4 5 . stop 99 0 1 6 .
If this doesn't help, we'll have to reconsider the possibility that there's something wrong with the script itself.
|
|
|
09-03-2004, 02:34 PM
|
#12
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by Dead Parrot
First remove all existing symlinks for the "local" script:
# update-rc.d -f local remove
Then add a new symlink S99local to /etc/rc2.d/ (and K99local to appropriate runlevels to stop the service in system shutdown):
# update-rc.d local start 99 2 . stop 99 0 1 6 .
...
If this doesn't help, we'll have to reconsider the possibility that there's something wrong with the script itself.
|
I followed your instructions and still no...
Just to check, I then ran (as root):
Debian:~$ /etc/rc2.d/S99local
Debian:~$ pidof SentryII
4638
It runs fine from the link.
So I'm stumped...
By the way, it will not work if I run the command as a user... I have to be logged in as root. (I also checked again in dmesg and /var/log/messages and I see no errors or reference to /etc/rc2.d/S99local for that matter.)
Thanks for the help and let me know if you have any other ideas!
|
|
|
09-03-2004, 03:08 PM
|
#13
|
Senior Member
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170
|
Quote:
Originally posted by robbow52
I followed your instructions and still no...
Just to check, I then ran (as root):
Debian:~$ /etc/rc2.d/S99local
Debian:~$ pidof SentryII
4638
It runs fine from the link.
So I'm stumped...
By the way, it will not work if I run the command as a user... I have to be logged in as root. (I also checked again in dmesg and /var/log/messages and I see no errors or reference to /etc/rc2.d/S99local for that matter.)
Thanks for the help and let me know if you have any other ideas!
|
Put touch /root/test.txt in the /etc/init.d/local file to make sure it is being accessed and run at boot then file should be created on the next boot. And you can always try with this near the bottom of /etc/init.d/bootmisc.sh.
Code:
if [ -f /etc/init.d/local ]; then
./etc/init.d/local
fi
Edit: Just to ask the obvious but you have chmod +x /etc/init.d/local to make the script file executable right?
Last edited by HappyTux; 09-03-2004 at 03:11 PM.
|
|
|
09-03-2004, 04:30 PM
|
#14
|
Member
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110
Original Poster
Rep:
|
Quote:
Originally posted by HappyTux
Put touch /root/test.txt in the /etc/init.d/local file to make sure it is being accessed and run at boot then file should be created on the next boot. And you can always try with this near the bottom of /etc/init.d/bootmisc.sh.
Edit: Just to ask the obvious but you have chmod +x /etc/init.d/local to make the script file executable right?
|
Debian:~$ ls -la /etc/init.d/local
-rwxr-xr-x 1 root root 65 Sep 3 16:23 /etc/init.d/local
I added the "touch" line to the end of local (after the line to start the SentryII daemon), and the /root/test.txt file was created on reboot so it would appear the script itself is running fine. The SentryII daemon which is supposed to be started by the script was still not started...
HOWEVER, for a change I decided to ctrl+alt+f1 into a console instead of a terminal window in Gnome (I know, I should have done this first!) to see the "end" of the boot... Dmesg does not show it nor does /var/log/messages, but after init starts run level 2 you can see:
/etc/rc2.d/S99local: line 4: SentryII: command not found
This is the exact error that I receive if I attempt to run the command as a normal user! If I log into a terminal as root, or su, and run the command, things run fine...
Am I going to have to resign myself to starting this manually?
Thanks for the ideas everyone and if someone has a thought I'm open to suggestions!
|
|
|
09-03-2004, 05:46 PM
|
#15
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
Well, the script seems to be executed during boot, and that's good news.
Next I'd suggest that you modify the /etc/init.d/local script as follows:
Code:
#!/bin/sh
if [ -x /usr/local/sbin/SentryII ]; then
/usr/local/sbin/SentryII daemon -c ./SentryII.ini
fi
If this doesn't help, then perhaps you should loosen up the access permissions for the SentryII file. I've understood that Sentry is some sort of security-related program so I hesitate to recommend that you should do "chmod 4755 /usr/local/sbin/SentryII", but at least you should run "ls -l /usr/local/sbin" to check the owner and group of SentryII.
Also, I'd suggest that you check the documentation that came with this Sentry program to see if any unusual actions are required to automatically start the daemon (editing /etc/group or something like that).
|
|
|
All times are GMT -5. The time now is 03:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|