rc-help.sh should use standard ecolours vs its internal ideas

This commit is contained in:
Roy Marples 2007-12-03 16:16:48 +00:00
parent 52b6cd1c9b
commit bf8d8a9be7

View File

@ -18,34 +18,20 @@
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # OR SVCNAMES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
if yesno ${RC_NOCOLOR}; then . /etc/init.d/functions.sh
unset BLUE GREEN OFF CYAN
else
BLUE="\033[34;01m"
GREEN="\033[32;01m"
OFF="\033[0m"
CYAN="\033[36;01m"
fi
myscript=$1 myscript=$1
if [ -z "${myscript}" ]; then if [ -z "${SVCNAME}" -o -z "$myscript" ]; then
echo "Please execute an init.d script" echo "Please execute an init.d script"
exit 1 exit 1
fi fi
if [ -L "${myscript}" ]; then
SERVICE=$(readlink "${myscript}")
else
SERVICE=${myscript}
fi
SERVICE=${SERVICE##*/}
if [ "$2" = "help" ]; then if [ "$2" = "help" ]; then
BE_VERBOSE="yes" BE_VERBOSE="yes"
NL="\n" NL="\n"
@ -57,30 +43,30 @@ fi
default_commands="describe help start status stop restart zap" default_commands="describe help start status stop restart zap"
extra_commands="$(. "${myscript}" 2>/dev/null; echo "${extra_commands:-${opts}}")" extra_commands="$(. "${myscript}" 2>/dev/null; echo "${extra_commands:-${opts}}")"
printf "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} > printf "Usage: ${HILITE}${SVCNAME}${NORMAL} [ ${GOOD}flags${NORMAL} ] < ${GOOD}options${NORMAL} >
${CYAN}Normal Commands:${OFF}" ${HILITE}Normal Commands:${NORMAL}"
if yesno ${BE_VERBOSE}; then if yesno ${BE_VERBOSE}; then
printf " printf "
${GREEN}describe${OFF} ${GOOD}describe${NORMAL}
Describe what the service and any extra options do. Describe what the service and any extra options do.
${GREEN}help${OFF} ${GOOD}help${NORMAL}
This screen - duh. This screen - duh.
${GREEN}start${OFF} ${GOOD}start${NORMAL}
Start service, as well as the services it depends on (if not already Start service, as well as the services it depends on (if not already
started). started).
${GREEN}status${OFF} ${GOOD}status${NORMAL}
Display the current status of the service. Display the current status of the service.
${GREEN}stop${OFF} ${GOOD}stop${NORMAL}
Stop service, as well as the services that depend on it (if not already Stop service, as well as the services that depend on it (if not already
stopped). stopped).
${GREEN}restart${OFF} ${GOOD}restart${NORMAL}
Restart service, as well as the services that depend on it. Restart service, as well as the services that depend on it.
Note to developers: If this function is replaced with a custom one, Note to developers: If this function is replaced with a custom one,
@ -89,33 +75,33 @@ printf "
can be handled correctly. Refer to the portmap rc-script for an can be handled correctly. Refer to the portmap rc-script for an
example. example.
${GREEN}zap${OFF} ${GOOD}zap${NORMAL}
Reset a service that is currently stopped, but still marked as started, Reset a service that is currently stopped, but still marked as started,
to the stopped state. Basically for killing zombie services. to the stopped state. Basically for killing zombie services.
${GREEN}status${OFF} ${GOOD}status${NORMAL}
Prints \"status: started\" if the service is running, else it Prints \"status: started\" if the service is running, else it
prints \"status: stopped\". prints \"status: stopped\".
Note that if the '--quiet' flag is given, it will return true if the Note that if the '--quiet' flag is given, it will return true if the
service is running, else false. service is running, else false.
${GREEN}ineed|iuse${OFF} ${GOOD}ineed|iuse${NORMAL}
List the services this one depends on. Consult the section about List the services this one depends on. Consult the section about
dependencies for more info on the different types of dependencies. dependencies for more info on the different types of dependencies.
${GREEN}needsme|usesme${OFF} ${GOOD}needsme|usesme${NORMAL}
List the services that depend on this one. Consult the section about List the services that depend on this one. Consult the section about
dependencies for more info on the different types of dependencies. dependencies for more info on the different types of dependencies.
${GREEN}broken${OFF} ${GOOD}broken${NORMAL}
List the missing or broken dependencies of type 'need' this service List the missing or broken dependencies of type 'need' this service
depends on. depends on.
" "
else else
printf " ${GREEN}${default_commands}${OFF} printf " ${GOOD}${default_commands}${NORMAL}
Default init.d options. Default init.d options.
" "
@ -123,28 +109,28 @@ fi
if [ -n "${extra_commands}" ]; then if [ -n "${extra_commands}" ]; then
printf " printf "
${CYAN}Additional Options:${OFF}${NL} ${HILITE}Additional Options:${NORMAL}${NL}
${GREEN}${extra_commands}${OFF} ${GOOD}${extra_commands}${NORMAL}
Extra options supported by this init.d script. Extra options supported by this init.d script.
" "
fi fi
printf " printf "
${CYAN}Flags:${OFF}${NL} ${HILITE}Flags:${NORMAL}${NL}
${GREEN}--ifstarted${OFF} Only do actions if service started ${GOOD}--ifstarted${NORMAL} Only do actions if service started
${GREEN}--nodeps${OFF} Don't stop or start any dependencies ${GOOD}--nodeps${NORMAL} Don't stop or start any dependencies
${GREEN}--quiet${OFF} ${GOOD}--quiet${NORMAL}
Suppress output to stdout, except if:${NL} Suppress output to stdout, except if:${NL}
1) It is a warning, then output to stdout 1) It is a warning, then output to stdout
2) It is an error, then output to stderr${NL} 2) It is an error, then output to stderr${NL}
${GREEN}--verbose${OFF} Output extra information ${GOOD}--verbose${NORMAL} Output extra information
${GREEN}--debug${OFF} Output debug information ${GOOD}--debug${NORMAL} Output debug information
${GREEN}--nocolor${OFF} Suppress the use of colors ${GOOD}--nocolor${NORMAL} Suppress the use of colors
" "
if yesno ${BE_VERBOSE}; then if yesno ${BE_VERBOSE}; then
printf " printf "
${CYAN}Dependencies:${OFF} ${HILITE}Dependencies:${NORMAL}
This is the heart of the OpenRC, as it determines the order This is the heart of the OpenRC, as it determines the order
in which services gets started, and also to some extend what services in which services gets started, and also to some extend what services
@ -163,20 +149,20 @@ ${CYAN}Dependencies:${OFF}
long as there is only one entry for each type, listing all its dependencies long as there is only one entry for each type, listing all its dependencies
on one line only. on one line only.
${GREEN}need${OFF} ${GOOD}need${NORMAL}
These are all the services needed for this service to start. If any These are all the services needed for this service to start. If any
service in the 'need' line is not started, it will be started even if it service in the 'need' line is not started, it will be started even if it
is not in the current, or 'boot' runlevel, and then this service will be is not in the current, or 'boot' runlevel, and then this service will be
started. If any services in the 'need' line fails to start or is started. If any services in the 'need' line fails to start or is
missing, this service will never be started. missing, this service will never be started.
${GREEN}use${OFF} ${GOOD}use${NORMAL}
This can be seen as representing optional services this service depends on This can be seen as representing optional services this service depends on
that are not critical for it to start. For any service in the 'use' line, that are not critical for it to start. For any service in the 'use' line,
it must be added to the 'boot' or current runlevel to be considered a it must be added to the 'boot' or current runlevel to be considered a
valid 'use' dependency. It can also be used to determine startup order. valid 'use' dependency. It can also be used to determine startup order.
${GREEN}before${OFF} ${GOOD}before${NORMAL}
This, together with the 'after' dependency type, can be used to control This, together with the 'after' dependency type, can be used to control
startup order. In core, 'before' and 'after' do not denote a dependency, startup order. In core, 'before' and 'after' do not denote a dependency,
but should be used for order changes that will only be honoured during but should be used for order changes that will only be honoured during
@ -184,11 +170,11 @@ ${CYAN}Dependencies:${OFF}
current service. In other words, this service will get started *before* current service. In other words, this service will get started *before*
all listed services. all listed services.
${GREEN}after${OFF} ${GOOD}after${NORMAL}
All services listed will be started *before* the current service. Have a All services listed will be started *before* the current service. Have a
look at 'before' for more info. look at 'before' for more info.
${GREEN}provide${OFF} ${GOOD}provide${NORMAL}
This is not really a dependency type, rather it will enable you to create This is not really a dependency type, rather it will enable you to create
virtual services. This is useful if there is more than one version of virtual services. This is useful if there is more than one version of
a specific service type, system loggers or crons for instance. Just a specific service type, system loggers or crons for instance. Just
@ -196,7 +182,7 @@ ${CYAN}Dependencies:${OFF}
of a system logger depend on 'logger'. This should make things much more of a system logger depend on 'logger'. This should make things much more
generic. generic.
${GREEN}config${OFF} ${GOOD}config${NORMAL}
This is not really a dependency type, rather it informs the dependency This is not really a dependency type, rather it informs the dependency
system about config files that may affect the dependencies of the service. system about config files that may affect the dependencies of the service.
One example of this is the netmount service which changes its dependencies One example of this is the netmount service which changes its dependencies
@ -221,7 +207,7 @@ ${CYAN}Dependencies:${OFF}
recommend using it with the 'need' or 'use' dependency type ... you have recommend using it with the 'need' or 'use' dependency type ... you have
been warned! been warned!
${CYAN}'net' Dependency and 'net.*' Services:${OFF} ${HILITE}'net' Dependency and 'net.*' Services:${NORMAL}
Example: Example:
@ -242,7 +228,7 @@ ${CYAN}'net' Dependency and 'net.*' Services:${OFF}
fi fi
printf " printf "
${CYAN}Configuration files:${OFF} ${HILITE}Configuration files:${NORMAL}
" "
if yesno ${BE_VERBOSE}; then if yesno ${BE_VERBOSE}; then
@ -252,19 +238,19 @@ printf "
" "
fi fi
printf " /etc/conf.d/${SERVICE} printf " /etc/conf.d/${SVCNAME}
/etc/conf.d/${SERVICE}.\${RC_SOFTLEVEL} /etc/conf.d/${SVCNAME}.\${RC_SOFTLEVEL}
/etc/rc.conf /etc/rc.conf
\${RC_SOFTLEVEL} denotes the name of the runlevel" \${RC_SOFTLEVEL} denotes the name of the runlevel"
if yesno ${BE_VERBOSE}; then if yesno ${BE_VERBOSE}; then
printf " printf "
You can add extra dependencies to ${SERVICE} by adding some variables to You can add extra dependencies to ${SVCNAME} by adding some variables to
/etc/conf.d/${SERVICE} /etc/conf.d/${SVCNAME}
rc_need=\"openvpn ntpd\" rc_need=\"openvpn ntpd\"
rc_use=\"dns\" rc_use=\"dns\"
This makes ${SERVICE} need openvpn and ntpd, while it just uses dns. This makes ${SVCNAME} need openvpn and ntpd, while it just uses dns.
A good example of this is nfsmount needing openvpn if the nfs mounts in A good example of this is nfsmount needing openvpn if the nfs mounts in
/etc/fstab are over the vpn link. /etc/fstab are over the vpn link.
@ -273,7 +259,7 @@ fi
if yesno ${BE_VERBOSE}; then if yesno ${BE_VERBOSE}; then
printf "\n printf "\n
${CYAN}Management:${OFF} ${HILITE}Management:${NORMAL}
Services are added and removed via the 'rc-update' tool. Running it without Services are added and removed via the 'rc-update' tool. Running it without
arguments should give sufficient help. arguments should give sufficient help.