DebianThis 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.
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.
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???
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
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!)
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
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.
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).
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).
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.
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.
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!
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?
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?
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!
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.