Results 1 to 9 of 9

Thread: init scripts on debian

  1. #1
    Join Date
    Feb 2008
    Posts
    132

    init scripts on debian

    I installed a debian (7) box with directadmin and it seems all init script installed with directadmin contain the command "status"
    when performing a command /etc/init.d/directadmin status it replies with :

    /etc/init.d/directadmin: line 74: status: command not found


    :73 status)
    :74 status $PROGNAME

    it also does this with http

    /etc/init.d/httpd status
    /etc/init.d/httpd: line 111: status: command not found


    Do more people have this and is there a solution for the internal status command.

  2. #2
    Join Date
    Aug 2008
    Posts
    4,695
    You probably are missing a function script. My guess is /lib/lsb/init-functions isnt being linked in correctly.

  3. #3
    Join Date
    Feb 2008
    Posts
    132
    ok, but its a default install.. and have more problems with this install very strange..

  4. #4
    Join Date
    Feb 2008
    Posts
    132
    Quote Originally Posted by scsi View Post
    You probably are missing a function script. My guess is /lib/lsb/init-functions isnt being linked in correctly.
    btw I compared these two from centos and debian and inboth nothing is reffered to status

  5. #5
    Join Date
    Feb 2008
    Posts
    132
    Quote Originally Posted by scsi View Post
    You probably are missing a function script. My guess is /lib/lsb/init-functions isnt being linked in correctly.
    scsi thanks for the hint:

    it seems all init scripts installed by the directadmin custom build for debian are missing the the include path to the correct function file : /lib/lsb/init-functions (if this is the default for debian)
    for centos it seems: /etc/rc.d/init.d/functions

    to summarize: (copy and pasted)

    It's specific to whatever distribution you're running. Debian and Ubuntu have /lib/lsb/init-functions; SuSE has /etc/rc.status; none of them are compatible with the others. In fact, some distributions don't use /etc/init.d at all, or use it in an incompatible way (Slackware and Arch occur to me off the top of my head; there are others).

    so in the installer I must assume be a mistake for the custombuild 2.0

    when I add this to the directadmin init script then it works (these sections are copied from centos
    Code:
    __pids_var_run() {
            local base=${1##*/}
            local pid_file=${2:-/var/run/$base.pid}
    
            pid=
            if [ -f "$pid_file" ] ; then
                    local line p
                    read line < "$pid_file"
                    for p in $line ; do
                            [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
                    done
                    if [ -n "$pid" ]; then
                            return 0
                    fi
                    return 1 # "Program is dead and /var/run pid file exists"
            fi
            return 3 # "Program is not running"
    }
    
    # Output PIDs of matching processes, found using pidof
    __pids_pidof() {
            pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
                    pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
    }
    
    status() {
            local base pid pid_file=
    
            # Test syntax.
            if [ "$#" = 0 ] ; then
                    echo $"Usage: status [-p pidfile] {program}"
                    return 1
            fi
            if [ "$1" = "-p" ]; then
                    pid_file=$2
                    shift 2
            fi
            base=${1##*/}
    
            # First try "pidof"
            __pids_var_run "$1" "$pid_file"
            RC=$?
            if [ -z "$pid_file" -a -z "$pid" ]; then
                    pid="$(__pids_pidof "$1")"
            fi
            if [ -n "$pid" ]; then
                    echo $"${base} (pid $pid) is running..."
                    return 0
            fi
    
            case "$RC" in
                    0)
                            echo $"${base} (pid $pid) is running..."
                            return 0
                            ;;
                    1)
                            echo $"${base} dead but pid file exists"
                            return 1
                            ;;
            esac
            # See if /var/lock/subsys/${base} exists
            if [ -f /var/lock/subsys/${base} ]; then
                    echo $"${base} dead but subsys locked"
                    return 2
            fi
            echo $"${base} is stopped"
            return 3
    }
    [/code]

  6. #6
    Join Date
    Feb 2008
    Posts
    132
    the real fix would be to add the correct path for the distributions and in this case debian to the directadmin based init scripts it is there in older versions of directadmin but not this debian.

    I created on debian the following file: /lib/lsb/init-functions.d/directadminfix

    Code:
    cat > /lib/lsb/init-functions.d/directadminfix << EOF1
    __pids_var_run() {
            local base=${1##*/}
            local pid_file=${2:-/var/run/$base.pid}
    
            pid=
            if [ -f "$pid_file" ] ; then
                    local line p
                    read line < "$pid_file"
                    for p in $line ; do
                            [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
                    done
                    if [ -n "$pid" ]; then
                            return 0
                    fi
                    return 1 # "Program is dead and /var/run pid file exists"
            fi
            return 3 # "Program is not running"
    }
    
    # Output PIDs of matching processes, found using pidof
    __pids_pidof() {
            pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
                    pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
    }
    
    status() {
            local base pid pid_file=
    
            # Test syntax.
            if [ "$#" = 0 ] ; then
                    echo $"Usage: status [-p pidfile] {program}"
                    return 1
            fi
            if [ "$1" = "-p" ]; then
                    pid_file=$2
                    shift 2
            fi
            base=${1##*/}
    
            # First try "pidof"
            __pids_var_run "$1" "$pid_file"
            RC=$?
            if [ -z "$pid_file" -a -z "$pid" ]; then
                    pid="$(__pids_pidof "$1")"
            fi
            if [ -n "$pid" ]; then
                    echo $"${base} (pid $pid) is running..."
                    return 0
            fi
    
            case "$RC" in
                    0)
                            echo $"${base} (pid $pid) is running..."
                            return 0
                            ;;
                    1)
                            echo $"${base} dead but pid file exists"
                            return 1
                            ;;
            esac
            # See if /var/lock/subsys/${base} exists
            if [ -f /var/lock/subsys/${base} ]; then
                    echo $"${base} dead but subsys locked"
                    return 2
            fi
            echo $"${base} is stopped"
            return 3
    }
    EOF1

    now the function status and sub functions of __pids_var_run & __pids_pidof required by the centos status are added

    and we need to include the functions in the wrong install scripts on the top below the #!/bin/..

    debian:
    # Source function library.
    . /lib/lsb/init-functions

    the following init scripts seem to be wrong from the install (that uses the status functions)

    (I made a list with)
    Code:
    for i in `grep -lir "status)"`; do sh /etc/init.d/$i status; done | grep -i "status: command not found"
    Code:
    ./mysqld: line 51: status: command not found
    ./dovecot: line 68: status: command not found
    ./freshclam: line 44: status: command not found
    ./da-popb4smtp: line 62: status: command not found
    ./clamd: line 44: status: command not found
    ./proftpd: line 57: status: command not found
    ./pure-ftpd: line 49: status: command not found
    ./httpd: line 113: status: command not found
    ./directadmin: line 77: status: command not found
    ./exim: line 66: status: command not found
    I added
    Code:
    . /lib/lsb/init-functions
    to all these files..

    Code:
    cd /etc/init.d
    for i in "mysqld dovecot freshclam da-popb4smtp clamd proftpd pure-ftpd directadmin exim"; do sed -i 's/#!\/bin\/sh/#!\/bin\/sh\n\n# Source function library.\n. \/lib\/lsb\/init-functions\n/' /etc/init.d/$i; done
    sed -i 's/#!\/bin\/bash/#!\/bin\/bash\n\n# Source function library.\n. \/lib\/lsb\/init-functions\n/' /etc/init.d/httpd
    and check again:
    Code:
    for i in `grep -lir "status)"`; do ./$i status; done | grep -i "status: command not found"
    -su: ./skeleton: Permission denied
    you could add it also to the skeleton file to have newly created entries also corrected..
    Last edited by soulshepard; 02-26-2014 at 11:41 AM.

  7. #7
    Hello,

    In regards to the "status" call, I've just checked our test box and it throws the same error, so you're system is "normal" and likely matches everyone elses... that function was just never checked or implemented.
    Personally, I always run
    Code:
    ps ax | grep directadmin
    to see what's running.

    John

  8. #8
    Join Date
    May 2012
    Posts
    4
    edit file

    nano /etc/init.d/mysqld
    after

    SOCK=/tmp/mysql.sock

    add

    MPID="`pidof mysqld`"

    and replace

    status $PROGNAME
    with

    if [ ${MPID} > 0 ]; then
    echo -e "MYSQL Rouned By Pid:\t\t${MPID}"
    else
    echo -e "MYSQL Stoped:\t\t[STOPED ]"
    fi
    fixit..

    root@srv:~# service mysqld status
    MYSQL Rouned By Pid: 8931
    root@srv:~#

  9. #9
    Join Date
    Feb 2015
    Posts
    8

    Exclamation

    Hi guys.
    It all started with issue with proftpd after I had to reboot the server.
    Now all services are up, besides proftpd:
    Code:
    root@s1:/etc# service proftpd start
    /etc/init.d/proftpd: line 19: /etc/rc.d/init.d/functions: No such file or directory
    I can't start it from GUI as well.
    What is more interesting, I can not do anything with other services:
    Code:
    root@s1:/etc# service httpd status
    /etc/init.d/httpd: line 111: status: command not found
    Building from custombuild 2.0 does not change anything.
    Could you please help me?
    OS: Debian 7 x64

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •