Fedora startup script help

Muhammad Imran imranqau-PkbjNfxxIARBDgjK7y7TUQ at public.gmane.org
Fri Mar 10 04:23:38 UTC 2006


Sorry, forgot to mention that I can put a '&' after "daemon $SERVER" 
command, that would make it run in the background, but daemon is more than 
simply a process running in back-ground. I want to run it as daemon as 
opposed to a user process running in background.

thanks

>
>I am trying to run a perl/BASH script as a daemon upon entering run-level 
>3. Here is what I did:
>I copied a script from /etc/init.d and modified it: put sym links in 
>/etc/rc.d/rc3.d & rc0.d
>
>When system enters run level 3, it displays message "Starting my daemon". 
>However it doesn't detach from terminal and stays there. I am trying to run 
>it as daemon (detached from launching terminal) using daemon function in 
>shell startup script. but apparently its not working.
>
>Can anybody suggest a way to run a perl script as daemon upon startup on 
>Fedora?
>Any help/advice is highly appreciated.
>
>Here is what startup script looks like:
>#############
>#!/bin/bash
>
>SERVER=/usr/sbin/myfirewalld
>prog="Intrusion detection system"
>
>[ -f $SERVER ] || exit 0
>
>start() {
>        echo -n $"Starting $prog: "
>        daemon $SERVER
>        RETVAL=$?
>        [ "$RETVAL" = 0 ] && touch /var/lock/subsys/myfirewalld
>        echo
>}
>
>stop() {
>        echo -n $"Stoping $prog: "
>        kill -9 $SERVER 2>/dev/null
>        rm -f /var/lock/subsys/myfirewalld
>}
>
>case "$1" in
>  start)
>        start
>        ;;
>  stop)
>        stop
>        ;;
>  status)
>        status myfirewalld
>        ;;
>  restart|reload)
>        stop
>        start
>        ;;
>  *)
>        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
>        exit 1
>esac
>exit 0
>################ end of startup script ######################
>
>And here is a sample server/daemon BASH script:
>########################
>#!/bin/sh
>#loop forever
>while :
>do
>        # now sleep for 5 minutes
>        sleep 30
>        # after wakeup send message to all users
>        wall <<EOF
>                I am running.....
>EOF
>done
>###########################
>Obviously, I will replace this script with something more useful :) once i 
>figure it out how to run it detached from terminal;
>
>Regards,
>Imran.
>

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list