Typo
[linux_from_scratch_hints.git] / OLD / fancy-boot-scripts.txt
blob545dc6618c352df4e7bdd8fe0a9c4c31a542c36c
1 TITLE:          Fancy boot scripts
2 LFS VERSION:    2.3.5
3 AUTHOR:         Gabriel Sandor <gabriel@elvikingo.com.ar>
5 SYNOPSIS:
6         How to have fancy boot scripts, with green OKs and red FAILEDs, much like RedHat's bootscripts. (This is now part of the standard LFS, as of version 2.3.7)
8 HINT:
9 Whoever used Red Hat or Mandrake will be missing those fancy boot
10 scripts withe the green [  OK  ] for successful service or the red
11 [FAILED] for the (obviously) failed service, all perfectly aligned in
12 one column.
13 I was trying to hack those scripts to incrporate them to my LFS, but
14 those scripts are very complex, because they do a lot of checking that
15 we really don't need  (after all, we are configuring all by hand), and
16 also, I didn't want to put something I really don't understand. So I
17 extracted the cosmetics, and put them into the original LFS boot scripts
18 with almost no change.
20 Try it out:
21 First back-up your /etc/init.d directory
23 Create a new file  /etc/init.d/funcions, with the same permitions of the
24 other boot scripts
26 #!/bin/sh      Begin /etc/init.d/funcions
28 # First set up a default search path.
29 export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
31 # Get a sane screen with
32 [ -z "$COLUMNS" ] && COLUMNS=80
34 # Set some variables  (not all are necessary by now)
35 BOOTUP=color
36 RES_COL=65
37 MOVE_TO_COL="echo -en \\033[${RES_COL}G"
38 SETCOLOR_SUCCESS="echo -en \\033[1;32m"
39 SETCOLOR_FAILURE="echo -en \\033[1;31m"
40 SETCOLOR_WARNING="echo -en \\033[1;33m"
41 SETCOLOR_NORMAL="echo -en \\033[0;39m"
42 LOGLEVEL=1
44 # New version of check_status
46 check_status() {
47   if [ $? = 0 ]
48   then
49         echo_success
50         echo
51   else
52         echo_failure
53         echo
54   fi
57 #  This are the new functions
59 echo_success() {
60   [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
61   echo -en "[   "
62   [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
63   echo -en "OK"
64   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
65   echo -en "   ]"
66   echo -ne "\r"
67   return 0
69 echo_failure() {
70   [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
71   echo -en "[   "
72   [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
73   echo -en "FAILED"
74   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
75   echo -en "   ]"
76   echo -ne "\r"
77   return 1
80 # This one is not used by now, may be next version.........
82 echo_passed() {
83   [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
84   echo -en "[   "
85   [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
86   echo -en "PASSED"
87   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
88   echo -en "   ]"
89   echo -ne "\r"
90   return 1
93 # End /etc/init.d/functions
95 For this to work, you need to include this file in every boot script
96 that invokes the function "check_status" like this
98 # Begin /etc/init.d/bootscript
99 # Include the funtions file     Note the space between the dot and the
100 name of the file
101 . /etc/init.d/functions
103 rest of script
105 # End /etc/init.d/bootscript
108 Of course you need to remove the original function check_status from all
109 the boot scripts
110 And voila.......
112 Check they are working correctly with the command
114 /etc/init.d/bootscript stop | start | reload | restart
115 You can do something else to change the face of tour LFS
116 The gettys are able to display a message banner before the login prompt.
117 This banner text is taken from the file /etc/issue.
118 So, create a new file /etc/issue and put the following, leaving a first
119 line blank: (No comments here, everything is displayed)
122 Welcome to myhostname.mydomain
124  This is Linux From Scrath  release 1.3 (A_Name_you_Like)
125  Kernel 2.2.14 on an i686 on \l
128 Reboot. Then you'll see the banner in each console, before the login
129 prompt.
130 The escaped caracter "\l" will display the number of console you are in
131 as you have it in the inittab (/dev/tty?)
132 so if you want to strip the "/dev/" part, strip it from the inittab file
133 like this
135 1:2345:respawn:/sbin/agetty tty1 9600
138 Enjoy!
140 Gabriel