Changeset 27d23b1


Ignore:
Timestamp:
03/25/2022 09:19:53 AM (6 months ago)
Author:
Pierre Labastie <pierre.labastie@…>
Branches:
11.2, 11.2-rc1, multilib, s6-init, trunk, xry111/arm64, xry111/clfs-ng, xry111/queue-11.3
Children:
887af77
Parents:
17c6532
git-author:
Pierre Labastie <pierre.labastie@…> (03/22/2022 10:13:19 AM)
git-committer:
Pierre Labastie <pierre.labastie@…> (03/25/2022 09:19:53 AM)
Message:

Change semantics of S and K files

Presently, there are a lot of special cases:

  • runlevel 0 and 6 unconditionally run "script stop" if they find a Kxxscript symlink. This may lead to trying to stop an already stopped device if for example switching to runlevel 0/6 from runlevel 1. This can be fixed by stating the convention that it is the responsability of scripts to check that the service is running before killing it (or not running before starting it). Still, we shouldn't try to stop a service if it was marked K in the previous runlevel. And same for S files: we shouldn't try to start a service that was marked S in the previous runlevel. Note that changing runlevel is not a "reset": if a user has manually changed the state of a daemon, this state will remain the same upon changing runlevel if the S/K status of that dameon is the same in both runlevels.
  • Sxxscript symlinks in runlevel 0/6 are run as "script stop" instead of the more intuitive "script start". This does not interact well with LSB-tools (some scripts would need "Default-Start: S 0 6" but then it is impossible to get correct "Required-Start" or "Should-Start" fields). Furthermore, having a counter-intuitive behavior is error prone. So now runlevel 0/6 will run "script sart" for a Sxxscript.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • bootscripts/lfs/init.d/rc

    r17c6532 r27d23b1  
    77# Authors     : Gerard Beekmans  - gerard@linuxfromscratch.org
    88#             : DJ Lucas - dj@linuxfromscratch.org
    9 # Update      : Bruce Dubbs - bdubbs@linuxfromscratch.org
     9# Updates     : Bruce Dubbs - bdubbs@linuxfromscratch.org
     10#             : Pierre Labastie - pierre@linuxfromscratch.org
    1011#
    1112# Version     : LFS 7.0
    1213#
     14# Notes       : Updates March 24th, 2022: new semantics of S/K files
     15#               - Instead of testing that S scripts were K scripts in the
     16#                 previous runlevel, test that they were not S scripts
     17#               - Instead of testing that K scripts were S scripts in the
     18#                 previous runlevel, test that they were not K scripts
     19#               - S scripts in runlevel 0 or 6 are now run with
     20#                "script start" (was "script stop" previously).
    1321########################################################################
    1422
     
    145153[ -r /run/interactive ] && source /run/interactive
    146154
    147 # Attempt to stop all services started by the previous runlevel,
    148 # and killed in this runlevel
     155# Stop all services marked as K, except if marked as K in the previous
     156# runlevel: it is the responsibility of the script to not try to kill
     157# a non running service
    149158if [ "${previous}" != "N" ]; then
    150159   for i in $(ls -v /etc/rc.d/rc${runlevel}.d/K* 2> /dev/null)
     
    156165      fi
    157166
    158       suffix=${i#/etc/rc.d/rc$runlevel.d/K[0-9][0-9]}
    159       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
    160       sysinit_start=/etc/rc.d/rcS.d/S[0-9][0-9]$suffix
    161 
    162       if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
    163          if [ ! -f ${prev_start} -a  ! -f ${sysinit_start} ]; then
    164             MSG="WARNING:\n\n${i} can't be "
    165             MSG="${MSG}executed because it was not "
    166             MSG="${MSG}not started in the previous "
    167             MSG="${MSG}runlevel (${previous})."
    168             log_warning_msg "$MSG"
    169             continue
    170          fi
    171       fi
     167      suffix=${i#/etc/rc.d/rc${runlevel}.d/K[0-9][0-9]}
     168      [ -e /etc/rc.d/rc${previous}.d/K[0-9][0-9]$suffix ] && continue
    172169
    173170      run ${i} stop
     
    185182
    186183
    187 # Start all functions in this runlevel
     184# Start all services marked as S in this runlevel, except if marked as
     185# S in the previous runlevel
     186# it is the responsabily of the script to not try to start an already running
     187# service
    188188for i in $( ls -v /etc/rc.d/rc${runlevel}.d/S* 2> /dev/null)
    189189do
     190
    190191   if [ "${previous}" != "N" ]; then
    191       suffix=${i#/etc/rc.d/rc$runlevel.d/S[0-9][0-9]}
    192       stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix
    193       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
    194 
    195       [ -f ${prev_start} -a ! -f ${stop} ] && continue
     192      suffix=${i#/etc/rc.d/rc${runlevel}.d/S[0-9][0-9]}
     193      [ -e /etc/rc.d/rc${previous}.d/S[0-9][0-9]$suffix ] && continue
    196194   fi
    197195
    198196   check_script_status
    199       if [ "${SCRIPT_STAT}" == "1" ]; then
    200          SCRIPT_STAT="0"
    201          continue
    202       fi
    203 
    204    case ${runlevel} in
    205       0|6)
    206          run ${i} stop
    207          ;;
    208       *)
    209          run ${i} start
    210          ;;
    211    esac
     197   if [ "${SCRIPT_STAT}" == "1" ]; then
     198      SCRIPT_STAT="0"
     199      continue
     200   fi
     201
     202   run ${i} start
    212203
    213204   error_value=${?}
Note: See TracChangeset for help on using the changeset viewer.