⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.in

📁 Network Administration Visualized 网络管理可视化源码
💻 IN
字号:
#!/usr/bin/env bash## $Id: functions.in 3787 2007-01-03 15:44:47Z mortenv $# This file contains functions to be used by most or all shell scripts# in the NAV init.d directory.### Copyright 2002-2004 Norwegian University of Science and Technology## This file is part of Network Administration Visualized (NAV)## NAV is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## NAV is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with NAV; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA### Authors: Morten Vold <morten.vold@itea.ntnu.no># Credits: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>#prefix=@prefix@exec_prefix=@exec_prefix@sysconfdir=@sysconfdir@initdir=@initdir@bindir=@bindir@localstatedir=@localstatedir@daemon() {    $1    rc=$?    if [ $rc -eq 0 ]; then        echo -n "Ok"        return 0    else        echo -n "Failed"        return 1    fi}killproc() {    pid=`pidofproc $1`    if [ -z "$pid" ] ; then        return 1    fi    if checkpid $pid 2>&1; then        if kill $pid; then            echo -n "Ok"            return 0        else            echo -n "Unable to terminate the process ($pid)"            return 1        fi    else        echo -n "$1 is not running"        return 0    fi}status() {    local base=${1##*/}    local pid=`pidofproc $1`    if [ "$pid" != "" ] ; then        echo "$1 (pid $pid) is running...";        return 0    else        echo "$1 does not seem to be running...";        return 1    fi}# Check if $pid (could be plural) are runningcheckpid() {        while [ "$1" ]; do           ps -p "$1" >/dev/null 2>&1 && return 0           shift        done        return 1}pidofproc() {    local base=${1##*/}    local PIDOF=/sbin/pidof    local piddir="${localstatedir}/run"    # Attempt removing any extensions from the base and check for two    # pid files (so if base is pping.py, we check both pping.py.pid    # and pping.pid)    local pidfiles="${piddir}/${base}.pid ${piddir}/${base/.*/}.pid"    if [ ! -z "$DEBUG" ]; then echo Checking ${pidfiles}; fi    for pidfile in $pidfiles; do        if [ -f $pidfile ] ; then            local line p pid=            read line < $pidfile            for p in $line ; do                test -z "${p//[0-9]/}" && checkpid "$p" && pid="$pid $p"            done            if [ -n "${pid-:}" ] ; then                echo $pid                return 0            fi        elif [ ! -z "$DEBUG" ]; then            echo Could not find pidfile ${pidfile}        fi    done    # If no pid files were found, our last resort is to try the pidof    # command (if it exists)    if [ -x $PIDOF ]; then        $PIDOF -o $$ -o $PPID -o %PPID -x $1 || \        $PIDOF -o $$ -o $PPID -o %PPID -x ${base}    fi}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -