LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-02-2004, 08:08 PM   #1
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Rep: Reputation: 15
Question 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!
 
Old 09-02-2004, 08:55 PM   #2
redjokerx
Member
 
Registered: Aug 2004
Location: San Diego
Distribution: Slackware
Posts: 303

Rep: Reputation: 31
would a symlink work?
 
Old 09-02-2004, 11:51 PM   #3
osvaldomarques
Member
 
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Hi,
Try put a "cd /usr/local/sbin" before the line which calls the daemon in the script.
 
Old 09-03-2004, 07:02 AM   #4
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
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???
 
Old 09-03-2004, 07:03 AM   #5
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by redjokerx
would a symlink work?
A symlink "where" and to "what"?
 
Old 09-03-2004, 07:25 AM   #6
phatboyz
Member
 
Registered: Feb 2004
Location: Mooresville NC
Distribution: CentOS 4,Free BSD,
Posts: 358

Rep: Reputation: 30
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)
 
Old 09-03-2004, 09:09 AM   #7
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
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!)
 
Old 09-03-2004, 09:38 AM   #8
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
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.
 
Old 09-03-2004, 09:44 AM   #9
Dead Parrot
Senior Member
 
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597

Rep: Reputation: 46
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).
 
Old 09-03-2004, 11:34 AM   #10
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
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!
 
Old 09-03-2004, 11:53 AM   #11
Dead Parrot
Senior Member
 
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597

Rep: Reputation: 46
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.
 
Old 09-03-2004, 01:34 PM   #12
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
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!
 
Old 09-03-2004, 02:08 PM   #13
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
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 02:11 PM.
 
Old 09-03-2004, 03:30 PM   #14
robbow52
Member
 
Registered: Oct 2003
Location: Kentucky, USA
Distribution: Debian "SID"
Posts: 110

Original Poster
Rep: Reputation: 15
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!
 
Old 09-03-2004, 04:46 PM   #15
Dead Parrot
Senior Member
 
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597

Rep: Reputation: 46
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).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get script to run on boot Ook Slackware 7 03-05-2005 01:31 AM
Getting script to run at boot Andy@DP Linux - Newbie 4 06-05-2004 07:39 AM
Getting a script to run at boot IMNOboist Linux - Software 2 05-10-2004 01:48 AM
Script won't run at boot bugsbunny Slackware - Installation 6 04-19-2004 04:26 PM
Can't get script to run on boot rickenbacherus Linux - General 5 08-21-2003 10:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 09:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration