Re: writing an init.d script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just edit the one from anacron.  If you just need to run that command when
you first boot up, it does make more sense to put it in rc.local.  If
you're not actually starting up a program, the 'stop' and 'status'
commands don't usually make much sense.  Here's a modified init.d script
from anacron:

#!/bin/sh
# Startup script for lsmodemd
#
# chkconfig: 2345 95 05
# description: lsmodemd does something

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /usr/bin/lsmodemd ] || exit 0

prog="lsmodemd"

start() {
    echo -n $"Starting $prog: "
    if /usr/bin/lsmodemd --country=SA /dev/lsusb ; then
        touch /var/lock/subsys/$prog
        echo_success ; echo
    else
        echo_failure ; echo
    fi
}

stop() {
    echo -n $"Stopping $prog: "
    stopcmd="command to stop lsmodemd"
    if $stopcmd ; then
        rm -f /var/lock/subsys/$prog
        echo_success ; echo
    else
        echo_failure ; echo
    fi
}

case "$1" in
        start)
            start
            ;;

        stop)
            stop
            ;;

        status)
            if [ -f /var/lock/subsys/$prog ]; then
                echo "$prog is started."
            else
                echo "$prog is stopped."
            fi
            ;;
        restart)
            stop
            start
            ;;
        condrestart)
            # whatever a condrestart would be for lsmodemd
            ;;

        *)
            echo $"Usage: $0 {start|stop|restart|condrestart|status}"
            exit 1

esac

exit 0

# end of script

____________________________________________________________________________
Bob Shaffer II - Owner, Developer, System Operator - BobShaffersComputer.com
http://bobshafferscomputer.com/

/"\
\ /  ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
/ \


Chadley Wilson said:
> Hi could some please help me to create a script that will start a daemon
> for me.
> I have already posted this earlier, in a diff thread. But thought the
> subject calls for a new one.
> I have treid working from examples but am really stuck.
>
> I need this command to run when I start the PC.
> /usr/bin/lsmodemd --country=SA /dev/lsusb
>
> --
> Chadley - Linux Rocks
> Welcome to my world.
> ******************************************************************
> This mail is free for distribution. You are free to - delete it - resend
> it - use it in anyway that makes you happy. I am not responsible for it
> or its content due to ignorance.
> Enjoy the adventures of Linux
> *******************************************************************
>
>
>
> --
> fedora-list mailing list
> fedora-list@xxxxxxxxxx
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
>



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux