In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
To make the content of the script look better, load the system function. / etc/init.d/functions
Functions this script is for files in / etc/init.d. Provides some basic features to see what's in it. Umask,path will be set first, as well as the locale, and then the font color in several cases of success,failure,warning,normal will be set. Let's take a look at the important methods provided:
Checkpid: check whether pid already exists, and return 0 if one exists (by looking at the / proc directory)
Daemon: start a service. The start of some scripts in the / etc/init.d directory uses this
Killproc: kill a process. The stop of some scripts in the / etc/init.d directory uses this
Pidfileofproc: find the pid of a process
Pidofproc: similar to the above, except that I also looked for the pidof command
Status: returns the status of a service
Echo_success,echo_failure,echo_passed,echo_warning outputs all kinds of information separately.
Success,failure,passed,warning records logs separately and calls the corresponding methods
Action: prints some information and executes a given command, which calls the success,failure method based on the result of the command execution
Strstr: determine whether $1 contains $2
Confirm: displays the prompt message "Start service $1 (Y) es/ (N) o / (C) ontinue? [Y]" and returns the selection result
Detailed analysis:
#-*-Shell-script-*-
#
# functions This file contains functions to be used by most or all # comment: this script is called by almost all scripts under / etc/init.d/ because it contains a large number of
# shell scripts in the / etc/init.d directory. The basic function of #. It is also used by / etc/rc.d/rc.sysinit, such as success, action, failure, etc.
#
TEXTDOMAIN=initscripts # set the TEXTDOMAIN variable
Some systems use the message type specified by the LC_MESSAGES shell variable. Some other systems are based on
The value of the shell variable TEXTDOMAIN creates the name of the message type, possibly with the suffix '.mo'. If
If you use the TEXTDOMAIN variable, you may need to set the variable TEXTDOMAINDIR to point to the message type file
In the position of. There are also some systems that use both variables in this form: TEXTDOMAINDIR/LC_MESSAGES
/ Lc_Messages/TEXTDOMAIN.mo.
#
# Make sure umask is sane # make sure the umask of the root user is correct 022 (that is, rwxr-xr-x)
Umask 022
# Set up a default search path. # set the default PATH variable
PATH= "/ sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin" # defaults to / sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
Export PATH # exported as an environment variable
# Get a sane screen width # set the correct screen width
[- z "${COLUMNS:-}"] & & COLUMNS=80 # if the value of the COLUMNS variable is empty, it is set to 80 (column)
[- z "${CONSOLETYPE:-}"] & & CONSOLETYPE= "`/ sbin/ consoletype`" # if CONSOLETYPE is empty, set CONSOLETYPE to the value returned by the / sbin/consoletype command
# usually vt or pty or serial
#
If [- f / etc/sysconfig/i18n-a-z "${NOLOCALE:-}"]; then # if / etc/sysconfig/i18n exists and the value of the NOLOCALE variable is empty, then
. / etc/sysconfig/i18n # execute the / etc/sysconfig/i18n file to get the value of the LANG variable
If ["$CONSOLETYPE"! = "pty"]; then # if the current console type is not pty, but vt or serial, then
Case "${LANG:-}" in # makes a choice based on the value of LANG
Ja_JP* | ko_KR* | zh_CN* | zh_TW* | bn_* | bd_* | pa_* | hi_* | ta_* | gu_*) # if LANG is in Japanese, simplified Chinese, traditional Chinese, Korean, etc.
Export LC_MESSAGES=en_US # set LC_MESSAGES to en_US
Export LANG # is also exported as an environment variable
*)
Export LANG # if it is another type of language, export LANG directly
;
Esac
Else # if the current consle is pty
[- n "$LC_MESSAGES"] & & export LC_MESSAGES # and if LC_MESSAGES is not empty, export LC_MESSAGES directly
Export LANG
Fi
Fi
# *
Case statement: it can match the contents of a variable with multiple templates, and then determine which part of the code should be executed based on the template that successfully matched.
Use format:
Case matching motherboard in
Template 1 [| template 2]... ) statement group
Template 3 [| template 4]... ) statement group
Esac
The matching of case statements is the matching order from top to bottom. Therefore, the principle of writing case statements is from top to bottom, and templates from special to ordinary. In C language, there is a default template in the case statement, but in shell programming, the template may be written as * to accomplish the same function.
Templates for case statements support matching
Matches all cases that start with n: n *
Match all letters of yes of different sizes: [yY] [eE] [sS]
However, {} matching is not supported because the template can be used | to achieve the goal.
Routine:
#! / bin/sh
Echo "Please input\" yes\ "or\" no\ ""
Read var
Case "$var" in
[yY] [eE] [sS]) echo "Your input is YES"
[nN] [oO]) echo "Your input is YES"
*) echo "Input Error!"
Esac
Exit 0
# * #
#
# the following is to set font colors for success, failure, passed and warning
# Read in our configuration
If [- z "${BOOTUP:-}"]; then # first, if the BOOTUP variable is empty, then
If [- f / etc/sysconfig/init]; then # execute the / etc/sysconfig/init file if there is a / etc/sysconfig/init file
. / etc/sysconfig/init
Else # or we will set it manually
# This all seem confusing? Look in / etc/sysconfig/init
# or in / usr/doc/initscripts-*/sysconfig.txt
BOOTUP=color # first set the BOOTUP variable. The default is color.
The second setting of RES_COL=60 # is set to "[xxx]" after the output of which column on the screen. The default is column 60.
MOVE_TO_COL= "echo-en\ 033 [${RES_COL} G" # MOVE_TO_COL is used to print "OK" or "FAILED", or "PASSED", or the part before "WARNING" without "["
The font behind the SETCOLOR_SUCCESS= "echo-en\\ 033 [1th 32m" # SETCOLOR_SUCCESS setting is green
SETCOLOR_FAILURE= "echo-en\\ 033 [1th 31m" # SETCOLOR_FAILURE setting all the fonts to be output in red
SETCOLOR_WARNING= "echo-en\\ 033 [1x 33m" # SETCOLOR_WARNING setting the fonts to be output are all × × ×
The font output after the SETCOLOR_NORMAL= "echo-en\\ 033 [0scape 39m" # SETCOLOR_NORMAL setting is white (default)
LOGLEVEL=1
Fi
If ["$CONSOLETYPE" = "serial"]; then # if you log in through a serial port, cancel the color output altogether
BOOTUP=serial
MOVE_TO_COL=
SETCOLOR_SUCCESS=
SETCOLOR_FAILURE=
SETCOLOR_WARNING=
SETCOLOR_NORMAL=
Fi
Fi
# # #
If ["${BOOTUP:-}"! = "verbose"]; then # if the value of the BOOTUP variable is not verbose, then
INITLOG_ARGS= "- Q" # sets the value of INITLOG_ARGS to-Q (quiet mode)
Else # otherwise
INITLOG_ARGS= # empty the value of INITLOG_ARGS
Fi
#
# Check if $pid (could be plural) are running # defines a function checkpid () below to check whether the specified directory exists under / proc (for example, / proc/1/)
Checkpid () {# returns 0 if any one exists
Local I # local variable definition
For i in $*; do
[- d "/ proc/$i"] & & return 0
Done
Return 1 # returns 1 if all the parameters given do not exist in the corresponding directory
}
#
# A function to start a program. # the most important function is defined below, the daemon function, which is used to start a service. It is used in the start part of the script under / etc/init.d/.
Daemon () {
# Test syntax.
Local gotbase= force=
Local base= user= nice= bg= pid=
Nicelevel=0
While ["$1"! = "${1percent # [- +]}"]; the do # daemon function itself can specify multiple options, such as-- check,-- check=
Case $1 in
'') echo $"$0: Usage: daemon [+ /-nicelevel] {program}" # you can also specify a nice value
Return 1
-- check)
Base=$2
Gotbase= "yes"
Shift 2
-- check=?*)
Base=$ {1mm Mustco check=}
Gotbase= "yes"
Shift
-- user) # can also specify which user to run as (--user,-- user=)
User=$2
Shift 2
-- user=?*)
User=$ {1mm / m / m / user =}
Shift
-- force)
Force= "force" #-- force means to force run
Shift
[- +] [0-9] *)
Nice= "nice-n $1" # if the first parameter of daemon is a number, it is considered to be a nice value
Shift
*) echo $"$0: Usage: daemon [+ /-nicelevel] {program}"
Return 1
Esac
Done
# Save basename. # basename is to extract the last part from the full path of the server's binary program
[- z "$gotbase"] & & base=$ {1 million dollars /}
# See if it's already running. Look * only* at the pid file. # check whether the service is already running. But the daemon function only looks at the pid file.
If [- f / var/run/$ {base} .pid]; then # if the pid file for the service exists under / var/run, then
Local line p
Read line
< /var/run/${base}.pid # 从该 pid 文件每次读取一行,送给变量 line 。注意 pid 文件可能有多行,且不一定都是数字 for p in $line ; do # 对于 line 变量的每个 word 进行检查 [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" # 如果 p 全部是数字,且存在 /proc/$p/ 目录,则认为该数字是一个 pid ,把它加入到 pid 变量 done # 到最后 pid 变量的值可能是有多个由空格分隔的数字组成 fi [ -n "${pid:-}" -a -z "${force:-}" ] && return # 如果 pid 变量最终为空,则 force 变量为空(不强制启动),则返回 # make sure it doesn't core dump anywhere unless requested # 下面对该服务使用的资源作一些设置 ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/ dev/null 2 > & 1 # ulimit is to control the resources that can be used by the process started by the shell,-S means soft control, and-c refers to the largest core
# dump file size. Default is 0 if DEAMON_COREFILE_LIMIT is empty.
# if they set NICELEVEL in / etc/sysconfig/foo, honor it # if the / etc/sysconfi/foo file exists and there is a NICELEVEL variable in it, use it instead of the nice value after daemon
[- n "$NICELEVEL"] & & nice= "nice-n $NICELEVEL" # Note that the nice assignment here is in nice-n format, because nice itself can start commands, which is more convenient to use
# Echo daemon # if the value of BOOTUP is verbose, print a service name
["${BOOTUP:-}" = "verbose"-a-z "$LSB"] & & echo-n "$base"
# And start it up. # here's how to start it.
If [- z "$user"]; then # if the user variable is empty, it starts with root by default
$nice initlog $INITLOG_ARGS-c "$*" # execute nice-n initlog-Q-c "$*"
Else # if a user is specified, then
$nice initlog $INITLOG_ARGS-c "runuser-s / bin/bash-$user-c\" $*\ "" # execute nice-n initlog-Q-c "runuser-s / bin/bash-- c" $* "
Fi
["$?"-eq 0] & & success $"$base startup" | | failure $"$base startup" # if the above command is successful, a green [OK] is displayed, otherwise [FAILURE] is displayed.
}
#
# A function to stop a program. # define another important function, killproc, which will be used in the stop part of the script under / etc/init.d/
Killproc () {
RC=0 # RC is the final returned value, initialized to 0
# Test syntax.
If ["$#"-eq 0]; the syntax format of the then # killproc function is killproc [], for example, killproc sm-client 9
Echo $"Usage: killproc {program} [signal]"
Return 1
Fi
Notset=0 # noset is used to check whether the user has specified the signal to be used by kill
# check for second arg to be kill level
If [- n "$2"]; then # if $2 is not empty, the user has a set signal, then
Else # otherwise
The value of the notset=1 # notset variable is 1, while killlevel is'- 9' (KILL signal)
Killlevel= "- 9"
Fi
# add: note, this is not to say that when a user stops a service without a specified signal, it will be forced to kill by using kill-9 immediately, but first with TERM signal, and then with KILL.
# Save basename.
The name of the service can be obtained from base=$ {1 preferred services /} # basename.
# Find pid.
Pid= # clears the value of the pid variable Note that it does not mean that the value of the pid variable is equal to the execution result of the following script.
If [- f / var/run/$ {base} .pid]; find pid under then # as the daemon function above
Local line p
Read line
< /var/run/${base}.pid for p in $line ; do [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" done fi if [ -z "$pid" ]; then # 不过和 daemon 不同的是,一旦 pid 为空不会直接 return 而是尝试用 pid 命令再次查找 pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \ # -o 是用于忽略某个 pid ,-o $$ 是忽略当前 shell 的 pid、-o $PPID 是忽略 shell 的 pid pidof -o $$ -o $PPID -o %PPID -x $base` # -o %PPID 是忽略 pidof 命令的父进程,要查询的进程是 $1 (fullpath) 或者 $base fi # Kill it. if [ -n "${pid:-}" ] ; then # 如果 pid 的值最终不为空,则 [ "$BOOTUP" = "verbose" -a -z "$LSB" ] && echo -n "$base " # 且 BOOTUP 的值为 verbose ,且 LSB 变量不为空,则打印一个服务名 if [ "$notset" -eq "1" ] ; then # 如果 notset 变量不为1,表示用户没有指定信号,则 if checkpid $pid 2>& 1; then # calls checkpid $pid to check whether a process directory exists under / proc/, and if so
# TERM first, then KILL if not dead # try to use TERM message first, then use KILL signal
Kill-TERM $pid > / dev/null 2 > & 1 # execute kill-TERM $pid
Usleep 100000 # usleep is the same as sleep, but in 1 ppm. Dormant here for 1 second.
If checkpid $pid & & sleep 1 & & # if checkpid $pid still finds the existence of the / proc// directory, it means it hasn't been killed yet. Wait for 1 second.
Checkpid $pid & & sleep 3 & & # if there is still a check with checkpid after 1 second, wait another 3 seconds
Checkpid $pid; then # if still not killed, use the KILL signal
Kill-KILL $pid > / dev/null 2 > & 1 # execute kill-KILL to kill it
Usleep 100000 # wait 1 second
Fi
Fi
Checkpid $pid # check the pid directory again
RC=$? # and return the result to RC, which is the final state of killproc
["$RC"-eq 0] & & failure $"$base shutdown" | | success $"$base shutdown" # if the value of RC is 0, it means that kill-9 did not kill the process, then call the failure function, otherwise call success
RC=$ (! $RC))
# use specified level only # above is in the case of no signal specified, below is the signal specified by the user. For example, restart) or reload) section
Else # this else is for if ["$notset"-eq "1"]
If checkpid $pid; then # if a process is detected, then
Kill $killlevel $pid > / dev/null 2 > & 1 # executes the kill command, but uses the specified signal $killlevel
RC=$? # and return the status value to the variable RC
["$RC"-eq 0] & & success $"$base $killlevel" | failure $"$base $killlevel" # successful if RC is 0, call success; otherwise call failure function
Fi
Fi
Else # the else is for if [- n "${pid:-}"], that is, there is no pid file and the pidof command does not find pid.
Failure $"$base shutdown" # calls the failure function to indicate a failure to stop the service
RC=1 # and the value of RC is 1
Fi
# Remove pid file if any. # it may be necessary to delete the pid file depending on the situation
If ["$notset" = "1"]; then # if notset is not 1, that is, if the user does not specify a signal
Rm-f / var/run/$base.pid # automatically deletes the pid file under / var/run
Fi
Return $RC # and return RC as exit status
}
# add: since deleting the pid file is only for the case where notset is 1, because the-HUP signal (rereading configuration) does not kill the process, so its pid file cannot be deleted.
# for example:
# ps-ef | grep xinetd
Root 2635 1 0 12:25? 00:00:00 xinetd-stayalive-pidfile / var/run/xinetd.pid
#. / xinetd reload
Reloading configuration: [OK]
# ps-ef | grep xinetd
Root 2635 1 0 12:25? 00:00:00 xinetd-stayalive-pidfile / var/run/xinetd.pid
Root 3927 3412 0 16:43 pts/0 00:00:00 grep xinetd
# you can see that pid has not changed after reload
#
# A function to find the pid of a program. Looks * only* at the pidfile
# the following pidfileofproc function is similar to checkpid, but does not execute the pidof command, but only queries the pid file
Pidfileofproc () {
Local base=$ {1 million dollars /}
# Test syntax.
If ["$#" = 0]; then
Echo $"Usage: pidfileofproc {program}"
Return 1
Fi
# First try "/ var/run/*.pid" files
If [- f / var/run/$base.pid]; then
Local line p pid=
Read line
< /var/run/$base.pid for p in $line ; do [ -z "${p//[0-9]/}" -a -d /proc/$p ] && pid="$pid $p" done if [ -n "$pid" ]; then echo $pid return 0 fi fi } ################################################################################################# # A function to find the pid of a program. # 下面的 pidofproc 函数和上面的 pidfileofproc 函数类似,但多了一步 pidof 命令 pidofproc() { base=${1##*/} # Test syntax. if [ "$#" = 0 ]; then echo $"Usage: pidofproc {program}" return 1 fi # First try "/var/run/*.pid" files if [ -f /var/run/$base.pid ]; then local line p pid= read line < /var/run/$base.pid for p in $line ; do [ -z "${p//[0-9]/}" -a -d /proc/$p ] && pid="$pid $p" done if [ -n "$pid" ]; then echo $pid return 0 fi fi pidof -o $$ -o $PPID -o %PPID -x $1 || \ pidof -o $$ -o $PPID -o %PPID -x $base } #################################################################################### status() { # 注释 :下面的 status 函数是判断服务的状态,总共有4种 local base=${1##*/} local pid # Test syntax. if [ "$#" = 0 ] ; then echo $"Usage: status {program}" return 1 fi # First try "pidof" # 同样是查找 pid 先。直接使用 pidof 命令 pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \ pidof -o $$ -o $PPID -o %PPID -x ${base}` if [ -n "$pid" ]; then # 如果 pid 变量的值不为空,则表示找到进程, echo $"${base} (pid $pid) is running..." # 则打印 "xxx (pid nnn) is running " , return 0 # 并返回 0 fi # Next try "/var/run/*.pid" files # 如果 pidof 命令没有找到,则尝试从 pid 文件找 if [ -f /var/run/${base}.pid ] ; then read pid < /var/run/${base}.pid if [ -n "$pid" ]; then # 如果 pidof 命令找不到,但从 pid 文件找到了 pid ,则 echo $"${base} dead but pid file exists" # 打印 "xxx dead but pid file exists", return 1 # 并返回 1 fi fi # See if /var/lock/subsys/${base} exists # 如果 pidof 命令和 pid 文件都没有找到 pid ,则 if [ -f /var/lock/subsys/${base} ]; then # 如果在 /var/lock/subsys 下存在对应的文件,则 echo $"${base} dead but subsys locked" # 打印 "xxxx dead but subsys locked", return 2 # 并返回 2 fi echo $"${base} is stopped" # 如果 pidof 命令、pidf 文件都没有找到pid ,且没有别锁,则打印 "xxx is stopped" return 3 # 并返回3 } ########################################################################################### # 注释 :下面的 echo_xxx 函数就是真正在屏幕上打印 [ ok ] 、[ PASSED ]、[ FAILURE ]、[ WARNING ] 的部分了 echo_success() { # 下面是 echo_success 部分 [ "$BOOTUP" = "color" ] && $MOVE_TO_COL # 首先是打印 "[" 之前的空格 echo -n "[ " # 然后打印 "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS # 设置字体为红色 echo -n $"OK" # 打印 OK [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL # 返回字体为白色 echo -n " ]" # 打印 "]" echo -ne "\r" # 换行。 return 0 # 返回 0,其他一律返回 1 echo_failure() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE echo -n $"FAILED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" return 1 } echo_passed() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING echo -n $"PASSED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" return 1 } echo_warning() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING echo -n $"WARNING" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" return 1 } ################################################################################################## # Inform the graphical boot of our current state update_boot_stage() { if [ "$GRAPHICAL" = "yes" -a -x /usr/bin/rhgb-client ]; then /usr/bin/rhgb-client --update="$1" fi return 0 } ################################################################################################ # Log that something succeeded success() { # success 函数除了打印 [ xxx ] 之外,还会使用 initlog 记录信息 if [ -z "${IN_INITLOG:-}" ]; then initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 # -n 是 --name 的意思,-s 是 --string ,-e 是 --event ,1 表示完全成功 else # silly hack to avoid EPIPE killing rc.sysinit trap "" SIGPIPE echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >& 21
Trap-SIGPIPE
Fi
["$BOOTUP"! = "verbose"-a-z "$LSB"] & & echo_success
Return 0
}
# Log that something failed
Failure () {
Rc=$?
If [- z "${IN_INITLOG:-}"]; then
Initlog $INITLOG_ARGS-n $0-s "$1"-e 2 # failure-event is 2 is a failure
Else
Trap "" SIGPIPE
Echo "$INITLOG_ARGS-n $0-s\" $1\ "- e 2" > & 21
Trap-SIGPIPE
Fi
["$BOOTUP"! = "verbose"-a-z "$LSB"] & & echo_failure
[- x / usr/bin/rhgb-client] & & / usr/bin/rhgb-client-- details=yes
Return $rc
}
# Log that something passed, but may have had errors. Useful for fsck
Passed () {
Rc=$?
If [- z "${IN_INITLOG:-}"]; then
Initlog $INITLOG_ARGS-n $0-s "$1"-e 1 # passed-event is still 1
Else
Trap "" SIGPIPE
Echo "$INITLOG_ARGS-n $0-s\" $1\ "- e 1" > & 21
Trap-SIGPIPE
Fi
["$BOOTUP"! = "verbose"-a-z "$LSB"] & & echo_passed
Return $rc
}
# Log a warning
Warning () {
Rc=$?
If [- z "${IN_INITLOG:-}"]; then
Initlog $INITLOG_ARGS-n $0-s "$1"-e 1 # warning-- event is also 1
Else
Trap "" SIGPIPE
Echo "$INITLOG_ARGS-n $0-s\" $1\ "- e 1" > & 21
Trap-SIGPIPE
Fi
["$BOOTUP"! = "verbose"-a-z "$LSB"] & & echo_warning
Return $rc
}
#
# Run some action. Log its output. The other most important function is the # action function, which prints a prompt and executes a given command
Tion () {
STRING=$1
Echo-n "$STRING"
If ["${RHGB_STARTED}"! = ""-a-w / etc/rhgb/temp/rhgb-console]; then
Echo-n "$STRING" > / etc/rhgb/temp/rhgb-console
Fi
Shift
Initlog $INITLOG_ARGS-c "$*" & & success $"$STRING" | | failure $"$STRING"
Rc=$?
Echo
If ["${RHGB_STARTED}"! = ""-a-w / etc/rhgb/temp/rhgb-console]; then
If ["$rc" = "0"]; then
Echo_success > / etc/rhgb/temp/rhgb-console
Else
Echo_failed > / etc/rhgb/temp/rhgb-console
[- x / usr/bin/rhgb-client] & & / usr/bin/rhgb-client-- details=yes
Fi
Echo
Fi
Return $rc
}
#
The # returns OK if $1 contains $2 # strstr function determines whether the $1 string contains a $2 string. If so, it returns 0, otherwise it returns 1.
() {
["${1 return 2 *}" = "$1"] & &
Return 0
}
#
# Confirm whether we really want to run this service # confirm function is used for interactive startup service
Nfirm () {
[- x / usr/bin/rhgb-client] & & / usr/bin/rhgb-client-- details=yes
While:; do
Echo-n $"Start service $1 (Y) es/ (N) o / (C) ontinue? [Y]" # will print a prompt
Read answer
If strstr $"yY"$answer" | | ["$answer" = ""]; then # if the answer variable is y or Y
Return 0 # returns 0 (but not really started)
Elif strstr $"cC"$answer"; then # if answer is c or C, then
Rm-f / var/run/confirm # Delete / var/run/confirm file
[- x / usr/bin/rhgb-client] & & / usr/bin/rhgb-client-- details=no
Return 2 # returns 2
Elif strstr $"nN"$answer"; then # if answer is n or N, then
Return 1 # returns 1 directly
Fi
Done
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.