DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 15th October 2008
Xtender's Avatar
Xtender Xtender is offline
New User
 
Join Date: Jul 2008
Posts: 4
Thanked 0 Times in 0 Posts
Question rc.d startup script problem

hello!

i've tried to create my own statup script, but it doesn't work at startup. it works when run from within /usr/local/etc/rc.d/ directory manually, but not at startup.

i was trying to follow this guide: http://www.freebsd.org/doc/en_US.ISO...ing/index.html

Here is the script:
Code:
80# cat /usr/local/etc/rc.d/test
#!/bin/sh
. /etc/rc.subr
name="test"
rcvar=`set_rcvar`
start_cmd="${name}_start"
stop_cmd=":"
test_start()
{
/usr/bin/touch /var/log/`date "+%H-%M-%S"`-test.log
}
load_rc_config $name
run_rc_command "$1"
I have added test_enable="YES" to /etc/rc.conf:
Code:
80# ./test rcvar
# test
test_enable=YES
It works when invoked manually (well, started at 23:40):
Code:
80# ./test start && ls /var/log/ | grep test
23-40-22-test.log
It just doesn't work upon startup What am i missing?

Thank you!
Reply With Quote
  #2   (View Single Post)  
Old 15th October 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

ok, another blind guess....
you have your script in /usr/local/etc/rc.d/
try putting it in /etc/rc.d

OR
try putting test_enable=YES in /usr/local/etc/rc.conf
Reply With Quote
  #3   (View Single Post)  
Old 15th October 2008
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Thanked 36 Times in 34 Posts
Default

Quote:
Originally Posted by Xtender View Post
Code:
/usr/bin/touch /var/log/`date "+%H-%M-%S"`-test.log
Try using the full path of 'date': /bin/date

You should also add rcorder(8) keywords. It should at least be:
Code:
#!/bin/sh

# PROVIDE: test
# REQUIRE: DAEMON

. /etc/rc.subr

name="test"
rcvar=`set_rcvar`

load_rc_config ${name}

: ${test_enable="NO"}

start_cmd="${name}_start"
stop_cmd=":"

test_start()
{
/usr/bin/touch /var/log/`/bin/date "+%H-%M-%S"`-test.log
}

run_rc_command "$1"

Last edited by BSDKaffee; 15th October 2008 at 11:52 PM.
Reply With Quote
  #4   (View Single Post)  
Old 16th October 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 699
Thanked 90 Times in 81 Posts
Default

Scripts ending in .sh are considered "old-style" scripts, and are run in alphabetical order after all "new-style" scripts.

Scripts without .sh are treated as "new-style" scripts, and are parsed by rcorder(8) before being executed. rcorder requires some header comments to determine what the script depends on and when it can be run. You can view how rcorder sees things by running:
# rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
If you don't see your script listed there, then rcorder doesn't know about it. You're missing all the rcorder headers.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #5   (View Single Post)  
Old 16th October 2008
Xtender's Avatar
Xtender Xtender is offline
New User
 
Join Date: Jul 2008
Posts: 4
Thanked 0 Times in 0 Posts
Default

At the moment I just changed the extension of these files to .sh and it seems to work perfectly.
Code:
rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
command listed all my scripts in /usr/local/etc/rc.conf, so probably the problem is in headers or something else. Later on I'll investigate also the case without .sh extension and report the results

Thanks
Reply With Quote
  #6   (View Single Post)  
Old 16th October 2008
ddekok ddekok is offline
Port Guard
 
Join Date: May 2008
Posts: 38
Thanked 4 Times in 3 Posts
Default

Just out of curiosity, what are the permissions on your rc script?
Reply With Quote
  #7   (View Single Post)  
Old 16th October 2008
Xtender's Avatar
Xtender Xtender is offline
New User
 
Join Date: Jul 2008
Posts: 4
Thanked 0 Times in 0 Posts
Default

Code:
80# ls -la /usr/local/etc/rc.d | grep test
-r-xr-xr-x  1 root  wheel   204 Oct 15 23:31 test.sh
Reply With Quote
  #8   (View Single Post)  
Old 17th October 2008
ddekok ddekok is offline
Port Guard
 
Join Date: May 2008
Posts: 38
Thanked 4 Times in 3 Posts
Default

hmm, okay, my theory of not being executable just went out the window.
Reply With Quote
  #9   (View Single Post)  
Old 17th October 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 699
Thanked 90 Times in 81 Posts
Default

If it was a permissions issue, then he wouldn't be able to run it manually via ./test as in the OP.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Old 17th October 2008
ddekok ddekok is offline
Port Guard
 
Join Date: May 2008
Posts: 38
Thanked 4 Times in 3 Posts
Default

Quote:
Originally Posted by phoenix View Post
If it was a permissions issue, then he wouldn't be able to run it manually via ./test as in the OP.
Now, now, you can't expect me to take into consideration every little pixel on the screen, can you?
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
firefox startup very slow. bsdnewbie999 OpenBSD General 5 6th May 2009 05:30 AM
dhclient at startup bsdnewbie999 OpenBSD General 3 31st March 2009 03:55 AM
Tightvnc startup script not loading fonts - permission denied master-richie FreeBSD Ports and Packages 2 3rd August 2008 09:29 PM
Beep on startup? matt Programming 1 16th July 2008 08:33 AM
Problem: periodic script 800.loginfail anomie FreeBSD Security 1 5th May 2008 08:57 PM


All times are GMT. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick