Changeset f45bf82 for chapter07


Ignore:
Timestamp:
06/22/2001 09:00:46 PM (23 years ago)
Author:
Gerard Beekmans <gerard@…>
Branches:
10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 6.0, 6.1, 6.1.1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, v3_0, v3_1, v3_2, v3_3, v4_0, v4_1, v5_0, v5_1, v5_1_1, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
Children:
e87f37a9
Parents:
4e90962
Message:

Added [ ATTN ] warning message. instead of printing failed when a daemon
was already running, or already stopped, it'll now print "already
running [ attn ]" or "not running [ attn ]" in green characters

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@706 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter07/functions.xml

    r4e90962 rf45bf82  
    2121
    2222COL=70
     23WCOL=50
    2324SET_COL="echo -en \\033[${COL}G"
     25SET_WCOL="echo -en \\033[${WCOL}G"
    2426NORMAL="echo -en \\033[0;39m"
    2527SUCCESS="echo -en \\033[1;32m"
     28WARNING="echo -en \\033[1;33m"
    2629FAILURE="echo -en \\033[1;31m"
    2730
     
    7376                        $NORMAL
    7477                        echo "  ]"
     78                        ;;
     79                warning)
     80                        $SET_COL
     81                        echo -n "[ "
     82                        $WARNING
     83                        echo -n "ATTN"
     84                        $NORMAL
     85                        echo " ]"
    7586                        ;;
    7687                failure)
     
    141152# return value
    142153#
     154
    143155                $*
    144156                evaluate_retval
    145157        else
    146158#
    147 # The variable $pid was not empty, meaning it was already running. We
    148 # print [FAILED] now
    149 #
    150                 print_status failure
     159# The variable $pid was not empty, meaning it was already running. We'll
     160# print [ ATTN ] now
     161#
     162
     163                $SET_WCOL
     164                echo -n "Already running"
     165                print_status warning
    151166        fi
    152167
     
    216231# more PID's were found that belongs to the processes to be killed
    217232#
     233
    218234        if [ -n "$pid" ]
    219235        then
     236
    220237#
    221238# If no kill level was specified we'll try -TERM first and then sleep
    222239# for 2 seconds to allow the kill to be completed
    223240#
     241
    224242                if [ "$nolevel" = 1 ]
    225243                then
    226244                        /bin/kill -TERM $pid
     245
    227246#
    228247# If after -TERM the PID still exists we'll wait 2 seconds before
     
    251270# and we'll print [FAILED]
    252271#
     272
    253273                                print_status failure
    254274                        else
     275
    255276#
    256277# It was killed, remove possible stale PID file in /var/run and
    257278# print [  OK  ]
    258279#
     280
    259281                                /bin/rm -f /var/run/$base.pid
    260282                                print_status success
    261283                        fi
    262284                else
     285
    263286#
    264287# A kill level was provided. Kill with the provided kill level and wait
    265288# for 2 seconds to allow the kill to be completed
    266289#
     290
    267291                        /bin/kill $killlevel $pid
    268292                        if /bin/ps h $pid &gt; /dev/null 2&gt;&amp;1
     
    273297                        if [ $? = 0 ]
    274298                        then
     299
    275300#
    276301# If ps' return value is 0 it means it ran ok which indicates that the
     
    278303# the signal provided. Print [FAILED]
    279304#
     305
    280306                                print_status failure
    281307                        else
     308
    282309#
    283310# If the return value was 1 or higher it means the PID didn't exist
     
    285312# PID file and print [  OK  ]
    286313#
     314
    287315                                /bin/rm -f /var/run/$base.pid
    288316                                print_status success
     
    290318                fi
    291319        else
    292 #
    293 # The PID didn't exist so we can't attempt to kill it. Print [FAILED]
    294 #
    295                 print_status failure
     320
     321#
     322# The PID didn't exist so we can't attempt to kill it. Print [ ATTN ]
     323#
     324
     325                $SET_WCOL
     326                echo -n "Not running"
     327                print_status warning
    296328        fi
    297329}
     
    333365#
    334366
    335 
    336367        if [ -n "$2" ]
    337368        then
     
    376407                        evaluate_retval
    377408                else
     409
    378410#
    379411# Else we will use the provided signal
     
    384416                fi
    385417        else
    386 #
    387 # If $pid is empty no PID's have been found that belong to the process
    388 # and print [FAILED]
    389 #
    390 
    391                 print_status failure
     418
     419#
     420# If $pid is empty no PID's have been found that belong to the process.
     421# Print [ ATTN ]
     422#
     423
     424                $SET_WCOL
     425                echo -n "Not running"
     426                print_status warning
    392427        fi
    393428}
     
    419454        if [ -n "$pid" ]
    420455        then
     456
    421457#
    422458# If $pid contains something, the process is running, print the contents
    423459# of the $pid variable
    424460#
     461
    425462                echo "$1 running with Process ID $pid"
    426463                return 0
Note: See TracChangeset for help on using the changeset viewer.