common_script

来自「Linux嵌入式设计配套光盘,学习嵌入式设计可参考」· 代码 · 共 89 行

TXT
89
字号
#!/bin/bash# This is a generic start/stop/restart/status script. Use environment# variables to configure it for a particular daemon. This script relies on# .pid files to determine whether the daemon is already running.# The following are used by many of the startup scripts in this distro, but we# don't currently use them in this simple script.# . /etc/sysconfig/rc# . $rc_functions# . /etc/sysconfig/network# Configuration for this script is provided by the following environment# variables. See ./ladd or ./snmpd for examples.# START_CMD# PID_FILE# STARTING_MSG# STOPPING_MSG# NOT_RUNNING_MSG# RUNNING_MSG# USAGE_MSGcase "$1" in  start)    if [ -f $PID_FILE ]; then        PID=$(cat $PID_FILE)        if [ -d /proc/$PID ]; then            echo -n $RUNNING_MSG            echo -n -e "\040"		# Force space before PID.            echo $PID        else            echo $STARTING_MSG            $START_CMD        fi    else        echo $STARTING_MSG        $START_CMD    fi  ;;  stop)    if [ -f $PID_FILE ]; then        PID=$(cat $PID_FILE)        if [ -d /proc/$PID ]; then            echo $STOPPING_MSG            kill $PID            # Use "-f" since the process may have already removed the PID file            # on termination.            rm -f $PID_FILE        else            echo $NOT_RUNNING_MSG        fi    else        echo $NOT_RUNNING_MSG    fi  ;;  restart)    $0 stop    sleep 1    $0 start  ;;  status)    if [ -f $PID_FILE ]; then        PID=$(cat $PID_FILE)        if [ -d /proc/$PID ]; then            echo -n $RUNNING_MSG            echo -n -e "\040"		# Force space before PID.            echo $PID        else            echo $NOT_RUNNING_MSG        fi    else        echo $NOT_RUNNING_MSG    fi  ;;  *)    echo "Usage: $0 {start|stop|restart|status}"    exit 1    ;;esac

⌨️ 快捷键说明

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