Changeset 7925

Show
Ignore:
Timestamp:
02/17/07 19:16:25 (1 year ago)
Author:
dj
Message:

contrib/lsb-v3 - added Makefile, README, INSTALL, and other cleanups

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bootscripts/contrib/lsb-v3/README

    r7914 r7925  
    1 LSB-V3 
     1LSB-V3 README 
    22 
    3 Scripts based on content of lfs-bootscripts-20070203. 
     3The scripts contianed in this directory are a complete rewrite of the 
     4boot scripts from LFS-6.1 (updated for LFS-SVN about 2007-02-16).  As is 
     5usually the case with a rewrite, there have been many changes: 
    46 
     7LSB Version 3.1 Compliant Scripts - Immediately noticable are the LSB headers 
     8in the rc.d scripts themselves.  Each script contains a usable header to 
     9allow for automating both the installation of, and determining proper 
     10execution order for the startup scripts.  These values can also be used 
     11directly in parallel boot setups.  Additionally, messages are displayed in 
     12one single write to the screen, after exit status is determined, so that 
     13they can be used in parallel setups.  I am not sure if this was the only 
     14barrier to auto language translation in the previous bootscripts.  Further, 
     15the messages are created from parts and only written to the screen in a 
     16single command, so maybe no help at all WRT translated boot messages. 
     17 
     18LSB 3.1 Omissions - Unfortunately, this package is not completely LSB 
     19compliant as it lacks install-initd and remove-initd programs.  The current 
     20popular flavor of these programs is written in Python, which, as you should 
     21know, is not installed until BLFS.  I gave up on a bash version of these 
     22scripts when I lost scope about three bash arrays deep (hint: you only want 
     23to read from and write to disk one time at program start and end repectively). 
     24But do feel free to write a perl or bash implementation if you have the 
     25ability and patience to do so.  You might see a contrib directory appear in 
     26BLFS-Bootscripts someday in the future if there is any demand for the already 
     27writen Python version of these programs. 
     28 
     29Distribution Independent - this original goal for the LFS scripts has been 
     30stretched even further by providing both a global rc config file that 
     31contains (generally) static values, and a new rc.site config file to allow 
     32customization of messages as diplayed to the end user during the boot 
     33process.  The format of messages printed to the screen is adjustable 
     34here.  As well, the other options that were available in the previous 
     35versions of the lfs-bootscripts, and additional options as discussed below, 
     36are configurable by the /etc/sysconfig/rc.site file. 
     37 
     38Single Environment - The rc script has been rewritten completely to allow a 
     39single source of the boot configuration per runlevel change.  This config 
     40is inherited from rc's environment as opposed to being sourced everytime a 
     41script is run.  This results in a negledgable decrease in boot time, but 
     42it is just better in principle, assuming I didn't break anything.  For those 
     43familiar with the previous versions, the 'stty sane' bit comes to mind, but 
     44I haven't witnessed any dispaly amomolies, nor do I remember how to reproduce 
     45the situation that caused us to move that into the functions file before. 
     46 
     47Boot Logging - The previous incarnation of the boot log didn't begin 
     48recording events until the root filesystem was mounted read/write.  This has 
     49been corrected by providing a tempfs mount immediately after init hands 
     50control to the rc script.  The bootlog is generated on the tempfs and then 
     51passed to the log file before login.  Additionally, shutdown events are no 
     52longer recorded in the bootlog.  They were pretty much useless and it really 
     53wasn't what I'd call a *boot* log.  Boot logging is on by default and is 
     54configurable in the /etc/sysconfig/rc.site file. 
     55 
     56Interactive Boot - This feature has been included by default, and is a 
     57little more polished than my previous attempt.  It does introduce a two 
     58second delay in the boot process (so that you have time to press a button 
     59to select interactive mode).  This time value, and the option prompt itself, 
     60is configurable in the /etc/sysconfig/rc.site file. 
     61 
     62RC_BASE - The base directory for the bootscripts is now /etc, not 
     63/etc/rc.d.  This is mostly to conform with mainstream distros, but other 
     64boot methods do expect that /etc/init.d is the location of bootscripts. 
     65Some distros provide a rc.d direcorty with symlinks to the rc*.d and init.d 
     66directories, I have not done that.  /etc is the location now, get your 
     67flying fingers accustomed to it!  Of course, this is still configurable in 
     68/etc/sysconfig/rc.site, and if the change is too great, I'll put it back. 
     69 
     70LSB Functions - The previous lfs-bootscripts sourced a functions file 
     71located at /etc/rc.d/init.d/functions.  This file has been renamed 
     72lfs-functions to segregate it from the old.  Both old and new bootscripts 
     73can be used simultaneously in a SYS-V setup (with proper symlinks in place). 
     74LSB defined functions are used where possible, but the lfs-functions file 
     75provides, easy to use wraper functions that 
     76start/stop/reload/force-reload/restart programs, evaluate the numerical 
     77LSB return values, and print status messages to the screen.  Both LFS 
     78functions and LSB functions are documented directly in the scritps located 
     79at /etc/init.d/lfs-functions and /lib/lsb/init-functions respectively. 
     80 
     81Pretier - Yeah, I just couldn't handle all the grey text...  By default, 
     82successful boot messages are prefixed with a single green astrik character, 
     83warning messages with two yellow astirks, and failures are prefixed with 
     84three red astriks.  This just provides a second 'quick glance' status when 
     85watching the boot messages fly by.  Again, the prefixes are configurable (or 
     86completely removable) in the /etc/sysconfig/rc.site file. 
     87 
     88Complete Rewrite - Yep.  That doesn't mean that code wasn't reused when 
     89possible, so Nathan, Alexander, Jim, Matthew, Bryan, Gerard, Mathias, and 
     90countless other contributors (whose names I've forgotten and will promptly 
     91be reminded of (please)) are owed credit for these as well.  That said, 
     92at very least, this is a complete reorganisation that I've tested to the 
     93best of my ability, but there probably are some hidden bugs that will come 
     94to lite when used more frequently.  Please give me a shout *when* you find 
     95them. 
     96 
     97Thanks. 
     98 
     99-- DJ Lucas 
     100dj AT linuxfromscratch DOT org 
     101 
  • trunk/bootscripts/contrib/lsb-v3/init.d/lfs-functions

    r7914 r7925  
    77# to run successfully.  The calling script will exit with a return value of 5 # 
    88# if the binary does not exist, and a value of 6 if the needed config file is # 
    9 # unavailible as per LSB requirements.  This function accepts zero, one, or   # 
     9# unavailable as per LSB requirements.  This function accepts zero, one, or   # 
    1010# two string arguments.  If arguments are passed, the first must be a bin     # 
    1111# file.  If a second argument is passed, it is interpreted as the config      # 
     
    3838        fi 
    3939    fi 
     40} 
     41 
     42################################ loadproc() ################################### 
     43# loadproc is just a wraper to start_daemon for simple scripts, which will    # 
     44# require no arguments if $BIN_FILE is set.                                   # 
     45############################################################################### 
     46loadproc() 
     47{ 
     48    start_daemon "${BIN_FILE}" "${@}" 
     49} 
     50 
     51################################ endproc() #################################### 
     52# endproc, like loadproc, is just a wraper to killproc for simplicity and is  # 
     53# dependent on $BIN_FILE being set.                                           # 
     54############################################################################### 
     55endproc() 
     56{ 
     57    killproc "${BIN_FILE}" "${@}" 
    4058} 
    4159 
     
    127145          ;; 
    128146          5) 
    129             log_failure_msg "Starting ${MESSAGE} Error: Not availible!" 
     147            log_failure_msg "Starting ${MESSAGE} Error: Not available!" 
    130148            return "${error_value}" 
    131149          ;; 
     
    148166            ;; 
    149167          5) 
    150             log_failure_msg "Stopping ${MESSAGE} Error: Not availible!" 
     168            log_failure_msg "Stopping ${MESSAGE} Error: Not available!" 
    151169            return "${error_value}" 
    152170            ;; 
  • trunk/bootscripts/contrib/lsb-v3/init.d/template

    r7914 r7925  
    1515# X-LFS-Default-Start: S50 
    1616# X-LFS-Default-Stop:  K25 (this can be an S value if run after K scripts) 
    17 # X-LFS-Provided-By:   BOOK or Project (just an informative text field) 
     17# X-LFS-Provided-By:   LFS (BOOK or Project - just an informative text field) 
    1818### END INIT INFO 
    1919 
     20# Source the LSB init-functions, ours are pulled in from there. 
    2021. /lib/lsb/init-functions 
    2122 
    2223# These are optional, but required for chk_stat.  They will be used in  
    2324# the rest of the functions if defined, else you must provide a program 
    24 # name to control, and a message ('Starting Proper Program name...'  
    25 # or 'Stopping Name...') to evauate_retval.  See the documntaion. 
    26 MESSAGE="Some Proper Service" 
    27 BIN_FILE="/some/path/to/binary" 
    28 CONFIGFILE="/some/config/file (or nothing)" 
     25# name to control, and a message ('Starting Template Service...'  
     26# or 'Stoping Template Service...') to evauate_retval.  See the  
     27# documentaion in the lfs-fucntions file for more information. 
     28MESSAGE="Template Service" 
     29BIN_FILE="/some/path/to/template" 
     30CONFIGFILE="/etc/sysconfig/template.conf" 
    2931 
     32# check that $BIN_FILE exists and is executable, and $CONFIGFILE exists. 
    3033chk_stat 
     34 
     35# LSB Defined functions require that at least $BIN_FILE be passed to them, 
     36# where as lfs-functions will use the $BIN_FILE environment variable. 
     37# loadproc() and endproc() are just wrappers that pass everything on to  
     38# the LSB defined functions. 
    3139 
    3240case "${1}" in 
    3341    start) 
    34         start_daemon 
     42        #start_daemon "${BIN_FILE}" -arg1 -arg2 #... or: 
     43        loadproc -arg1 -arg2 -arg3 #... 
    3544        evaluate_retval start 
    3645        ;; 
    3746 
    3847    stop) 
    39         killproc 
     48        #killproc -TERM "${BIN_FILE}" or: 
     49        endproc 
    4050        evaluate_retval stop 
    4151        ;; 
     
    5565        ;; 
    5666 
    57 #    reload) 
    58 #        reloadproc 
    59 #        ;; 
    60 #    try-restart) 
    61 #        ;; 
     67# reload and try-restart are optional per LSB requirements 
     68    reload) 
     69        reloadproc 
     70        evaluate_retval reload 
     71        ;; 
     72 
     73    try-restart) 
     74        # Since this is optional there is no lfs-function for this one... 
     75        # might be at a later time if used enough, but I doubt it usefullness. 
     76        pidofproc "${BIN_FILE}" > /dev/null 
     77        if [ "${?}" -ne "0" ]; then 
     78            MESSAGE="${MESSAGE}: Not Running" 
     79        else 
     80            $0 stop 
     81            $0 start 
     82            exit 0 
     83        fi 
     84        evaluate_retval try-restart 
     85        ;; 
     86 
    6287    *) 
    63         echo "Usage: ${0} {start|stop|force-reload|restart|status}" 
     88        echo "Usage: ${0} {start|stop|{force-}reload|{try-}restart|status}" 
    6489        exit 1 
    6590        ;;