MyDNS CentOS start on Reboot

Discussion in 'HOWTO-Related Questions' started by kaptk2, Mar 6, 2006.

  1. kaptk2

    kaptk2 New Member

    When following the MyDNS howto I get to this step:

    On Fedora or RedHat, you would run this:

    chkconfig --levels 235 mydns on

    Upon running that command I get this error message:
    service mydns does not support chkconfig

    I am running CentOS 4.2 any hints on how to get it so that on a reboot MyDNS will come up.
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Is /etc/init.d/mydns executable?
     
  3. kaptk2

    kaptk2 New Member

    Yes it is.

    # ls -li /etc/init.d/mydns
    1378476 -rwxr-xr-x 1 root root 775 Mar 6 11:21 /etc/init.d/mydns
     
  4. falko

    falko Super Moderator ISPConfig Developer

    Ok, can you post the first lines of any other script in /etc/init.d? I guess you have to add something similar to /etc7init.d/mydns so that the chkconfig program knows what to do.
     
  5. kaptk2

    kaptk2 New Member

    After 2 days of trying to get this to work I still can't figure out what is missing. Here is the /etc/init.d/snmpd script in it entirity. Maybe you can see what I am missing. If you want a diffrent file let me know. SNMP seemed the easist for me to understand.

    Code:
    #!/bin/bash
    # ucd-snmp init file for snmpd
    #
    # chkconfig: - 50 50
    # description: Simple Network Management Protocol (SNMP) Daemon
    #
    # processname: /usr/sbin/snmpd
    # config: /etc/snmp/snmpd.conf
    # config: /usr/share/snmp/snmpd.conf
    # pidfile: /var/run/snmpd
    
    # source function library
    . /etc/init.d/functions
    
    OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
    RETVAL=0
    prog="snmpd"
    
    start() {
            echo -n $"Starting $prog: "
            if [ $UID -ne 0 ]; then
                    RETVAL=1
                    failure
            else
                    daemon /usr/sbin/snmpd $OPTIONS
                    RETVAL=$?
                    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
            fi;
            echo
            return $RETVAL
    }
    
    stop() {
            echo -n $"Stopping $prog: "
            if [ $UID -ne 0 ]; then
                    RETVAL=1
                    failure
            else
                    killproc /usr/sbin/snmpd
                    RETVAL=$?
                    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
            fi;
            echo
            return $RETVAL
    }
    
    reload(){
            echo -n $"Reloading $prog: "
            killproc /usr/sbin/snmpd -HUP
            RETVAL=$?
            echo
            return $RETVAL
    }
    
    restart(){
            stop
            start
    }
    
    condrestart(){
        [ -e /var/lock/subsys/snmpd ] && restart
        return 0
    }
    
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      restart)
            restart
            ;;
      reload)
            reload
            ;;
      condrestart)
            condrestart
            ;;
      status)
            status snmpd
            RETVAL=$?
            ;;
      *)
            echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
            RETVAL=1
    esac
    
    exit $RETVAL
    
     
  6. falko

    falko Super Moderator ISPConfig Developer

    Please put
    Code:
    # chkconfig: - 21 22
    somewhere at the beginning of /etc/init.d/mydns and run
    Code:
    chkconfig --levels 235 mydns on
     
  7. kaptk2

    kaptk2 New Member

    No good. I am still getting this error message:
    service mydns does not support chkconfig

    Here is how my file looks now. It is snipped but the rest is what is on the website. Any more hints?

    Code:
    #! /bin/sh
    #
    #
    # chkconfig: - 21 22
    #
    # mydns         Start the MyDNS server
    #
    # Author:       Falko Timme <[email protected]>.
    #
    
    set -e
    
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    NAME=mydns
    DAEMON=/usr/local/sbin/$NAME
    DESC="DNS server"
    
     
  8. falko

    falko Super Moderator ISPConfig Developer

    You can create the needed system startup links for mydns by hand:

    Code:
    ln -s /etc/init.d/mydns /etc/rc.d/rc2.d/S21mydns
    ln -s /etc/init.d/mydns /etc/rc.d/rc3.d/S21mydns
    ln -s /etc/init.d/mydns /etc/rc.d/rc5.d/S21mydns
     
  9. kaptk2

    kaptk2 New Member

    Fixed It!

    I finally fixed it so that it works with out manually adding anything. I edited the init script to look like this. And it works now with the instructions provided. It also now show up when you run ntsysv. Hope this helps somebody else in the future.

    Code:
    #! /bin/sh
    # mydns         Start the MyDNS server
    # Author:       Falko Timme <[email protected]>.
    
    # Comments to support chkconfig on RedHat Linux
    # chkconfig: 235 90 90
    # description: A DNS server that runs off of a MySQL backend
    
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    NAME=mydns
    DAEMON=/usr/local/sbin/$NAME
    DESC="DNS server"
    
    SCRIPTNAME=/etc/init.d/$NAME
    
    # Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0
    
    case "$1" in
      start)
            echo -n "Starting $DESC: $NAME"
            $DAEMON --background
            echo "."
            ;;
      stop)
            echo "Stopping $DESC: $NAME."
            kill -9 `pidof $NAME` &> /dev/null
            ;;
      restart)
            echo "Restarting $DESC: $NAME."
            $0 stop && sleep 1
            $0 start
            ;;
      *)
            echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
            exit 1
            ;;
    esac
    
    exit 0
    
     

Share This Page