Could someone give me some assistance in getting this startup script to conform to chkconfig and such where the service will start up after networking comes up, and then shut down when networking goes away? Where all do entries need to be made, and what would they consist of?
Many thanks.....
Sam ------------------------------------------------------------------------
#! /bin/sh export PATH=/bin:/usr/bin
LDMHOME=/usr/local/ldm LDMBIN=$LDMHOME/bin LDMADMIN=$LDMBIN/ldmadmin PQCHECK=$LDMBIN/pqcheck PQCAT=$LDMBIN/pqcat PQ=$LDMHOME/data/ldm.pq LOG="logger -p local0.err $0:"
case "$1" in
start) $LOG 'Starting LDM system...' if [ -x $LDMADMIN ] ; then if su - ldm -c "$LDMADMIN isrunning"; then $LOG "LDM system is already running." else if [ ! -f $PQ ] ; then $LOG "Product-queue doesn't exist. Creating..." if ! su - ldm -c "$LDMADMIN mkqueue"; then $LOG "Aborting..." exit 1 fi else # # Test the product-queue for corruption. # if ! $PQCHECK -l /dev/null -q $PQ; then case $? in 1) $LOG "System error checking product-queue. Aborting..." exit 1 ;; 2) $LOG "Adding writer-counter to product-queue..." if ! $PQCHECK -F -q $PQ; then $LOG "Aborting..." exit 1 fi ;; 3) $LOG "Product-queue was incorrectly closed. " \ "Checking..." if $PQCAT -s -l /dev/null; then $LOG "Product-queue appears OK. " $LOG "Clearing writer-counter..." if ! $PQCHECK -F -q $PQ; then $LOG "Couldn't clear counter. Aborting..." exit 1 fi else $LOG "Product-queue appears corrupt. Deleting." rm $PQ if ! su - ldm -c "$LDMADMIN mkqueue -f"; then $LOG "Couldn't make new product-queue. Aborting..." exit 1 fi fi ;; 4) $LOG "Product-queue is corrupt. Deleting." rm $PQ if ! su - ldm -c "$LDMADMIN mkqueue -f"; then $LOG "Couldn't make new product-queue. Aborting..." exit 1 fi ;; esac fi fi su - ldm -c "$LDMADMIN clean" su - ldm -c "$LDMADMIN start" fi fi ;;
stop) $LOG 'Stopping the LDM system.' if [ -x $LDMADMIN ] ; then su - ldm -c "$LDMADMIN stop" fi ;;
esac
On 01/06/06, Sam Drinkard sam@wa4phy.net wrote:
Could someone give me some assistance in getting this startup script to conform to chkconfig and such where the service will start up after networking comes up, and then shut down when networking goes away? Where all do entries need to be made, and what would they consist of?
On a simplistic level, just adding the chkconfig line somewhere near the top should do the job.
[wmcdonald@willspc ~]$ /sbin/chkconfig --list network network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [wmcdonald@willspc ~]$ grep chkconfig /etc/rc.d/init.d/network # chkconfig: 2345 10 90
So, network's starting in runlevels 2, 3, 4 & 5. It's starting with a weighting, or priority, of 10 and stopping with one of 90.
If you added something like...
# chkconfig: 345 20 80 # description: Does LDM stuff
... after your shabang #!/bin/sh line that should suffice. That would start your LDM script after networking in runlevels 345 and stop it before networking's stopped when hopping back down through the runleves.
I can't recall if you need a "chkconfig --add ldm" but if your script's not visible in "chkconfig --list" then try it. The chkconfig man page's RUNLEVEL FILES section should have all the info you need.
If you wanted to go the whole hog you could also look at integrating your startup stuff into /var/lock/subsys etc. Just have a look through an existing init script.
Will.
Will McDonald wrote:
On 01/06/06, Sam Drinkard sam@wa4phy.net wrote:
Could someone give me some assistance in getting this startup script to conform to chkconfig and such where the service will start up after networking comes up, and then shut down when networking goes away? Where all do entries need to be made, and what would they consist of?
On a simplistic level, just adding the chkconfig line somewhere near the top should do the job.
[wmcdonald@willspc ~]$ /sbin/chkconfig --list network network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [wmcdonald@willspc ~]$ grep chkconfig /etc/rc.d/init.d/network # chkconfig: 2345 10 90
So, network's starting in runlevels 2, 3, 4 & 5. It's starting with a weighting, or priority, of 10 and stopping with one of 90.
If you added something like...
# chkconfig: 345 20 80 # description: Does LDM stuff
... after your shabang #!/bin/sh line that should suffice. That would start your LDM script after networking in runlevels 345 and stop it before networking's stopped when hopping back down through the runleves.
I can't recall if you need a "chkconfig --add ldm" but if your script's not visible in "chkconfig --list" then try it. The chkconfig man page's RUNLEVEL FILES section should have all the info you need.
If you wanted to go the whole hog you could also look at integrating your startup stuff into /var/lock/subsys etc. Just have a look through an existing init script.
Will. _______________________________________________
Thanks Will, and others. Now if I can just get the script to be recognized! Really weird. If I do a ./ldm start, *from* that directory, it says "no such file" Not sure I quite understand why, but it's physically there.
Sam
On Jun 1, 2006, at 1:58 PM, Sam Drinkard wrote:
Will McDonald wrote:
On 01/06/06, Sam Drinkard sam@wa4phy.net wrote:
Could someone give me some assistance in getting this startup script to conform to chkconfig and such where the service will start up after networking comes up, and then shut down when networking goes away? Where all do entries need to be made, and what would they consist of?
On a simplistic level, just adding the chkconfig line somewhere near the top should do the job.
[wmcdonald@willspc ~]$ /sbin/chkconfig --list network network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [wmcdonald@willspc ~]$ grep chkconfig /etc/rc.d/init.d/network # chkconfig: 2345 10 90
So, network's starting in runlevels 2, 3, 4 & 5. It's starting with a weighting, or priority, of 10 and stopping with one of 90.
If you added something like...
# chkconfig: 345 20 80 # description: Does LDM stuff
... after your shabang #!/bin/sh line that should suffice. That would start your LDM script after networking in runlevels 345 and stop it before networking's stopped when hopping back down through the runleves.
I can't recall if you need a "chkconfig --add ldm" but if your script's not visible in "chkconfig --list" then try it. The chkconfig man page's RUNLEVEL FILES section should have all the info you need.
If you wanted to go the whole hog you could also look at integrating your startup stuff into /var/lock/subsys etc. Just have a look through an existing init script.
Will. _______________________________________________
Thanks Will, and others. Now if I can just get the script to be recognized! Really weird. If I do a ./ldm start, *from* that directory, it says "no such file" Not sure I quite understand why, but it's physically there.
Sam
-- Sam W.Drinkard -- sam@wa4phy.net WEB http://wa4phy.net Augusta Mesonet cell 706.825.8513 Home 706.868.7253 MAIL 4438 Branchwood Drive, Martinez Georgia, 30907-1304
<sam.vcf> _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Whenever I'm troubleshooting startup files, or shell scripts in general, I find that running it like [root@foo.com init.d]# sh -x httpd start helps. It runs the script file and traces each line, so you can see where it fails.
If it were a bad shebang line, I would expect to see (under CentOS 4.3) [root@foo.com init.d]# ./httpd start -bash: ./httpd: /bin/bashr: bad interpreter: No such file or directory
HTH
Michael
On Thu, 2006-06-01 at 14:39 -0400, Michael Grinnell wrote:
On Jun 1, 2006, at 1:58 PM, Sam Drinkard wrote:
Will McDonald wrote:
On 01/06/06, Sam Drinkard sam@wa4phy.net wrote:
<snip>
Whenever I'm troubleshooting startup files, or shell scripts in general, I find that running it like [root@foo.com init.d]# sh -x httpd start helps. It runs the script file and traces each line, so you can see where it fails.
If it were a bad shebang line, I would expect to see (under CentOS 4.3) [root@foo.com init.d]# ./httpd start -bash: ./httpd: /bin/bashr: bad interpreter: No such file or directory
I still think that either the symlink points to a non-existent target or, as another post said, bad acl/owner/permissions. But it could be from a command issued inside the script that points to something bad? Then the -x trace would nail it.
HTH
Michael
<snip sig stuff>