aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-12-03 16:16:48 +0000
committerRoy Marples <roy@marples.name>2007-12-03 16:16:48 +0000
commitbf8d8a9be7e45120e11fb68c493f61b58e87a537 (patch)
tree4215e8d1470096888b982c0175a4b7773d2b8809 /sh
parent52b6cd1c9be5b7c4c0ed16c69239ae2c6839fba0 (diff)
rc-help.sh should use standard ecolours vs its internal ideas
Diffstat (limited to 'sh')
-rwxr-xr-xsh/rc-help.sh96
1 files changed, 41 insertions, 55 deletions
diff --git a/sh/rc-help.sh b/sh/rc-help.sh
index f2345708..fcd6b7a6 100755
--- a/sh/rc-help.sh
+++ b/sh/rc-help.sh
@@ -18,34 +18,20 @@
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# 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
# 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
# SUCH DAMAGE.
-if yesno ${RC_NOCOLOR}; then
- unset BLUE GREEN OFF CYAN
-else
- BLUE="\033[34;01m"
- GREEN="\033[32;01m"
- OFF="\033[0m"
- CYAN="\033[36;01m"
-fi
+. /etc/init.d/functions.sh
myscript=$1
-if [ -z "${myscript}" ]; then
+if [ -z "${SVCNAME}" -o -z "$myscript" ]; then
echo "Please execute an init.d script"
exit 1
fi
-if [ -L "${myscript}" ]; then
- SERVICE=$(readlink "${myscript}")
-else
- SERVICE=${myscript}
-fi
-SERVICE=${SERVICE##*/}
-
if [ "$2" = "help" ]; then
BE_VERBOSE="yes"
NL="\n"
@@ -57,30 +43,30 @@ fi
default_commands="describe help start status stop restart zap"
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
printf "
- ${GREEN}describe${OFF}
+ ${GOOD}describe${NORMAL}
Describe what the service and any extra options do.
- ${GREEN}help${OFF}
+ ${GOOD}help${NORMAL}
This screen - duh.
- ${GREEN}start${OFF}
+ ${GOOD}start${NORMAL}
Start service, as well as the services it depends on (if not already
started).
- ${GREEN}status${OFF}
+ ${GOOD}status${NORMAL}
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
stopped).
- ${GREEN}restart${OFF}
+ ${GOOD}restart${NORMAL}
Restart service, as well as the services that depend on it.
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
example.
- ${GREEN}zap${OFF}
+ ${GOOD}zap${NORMAL}
Reset a service that is currently stopped, but still marked as started,
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: stopped\".
Note that if the '--quiet' flag is given, it will return true if the
service is running, else false.
- ${GREEN}ineed|iuse${OFF}
+ ${GOOD}ineed|iuse${NORMAL}
List the services this one depends on. Consult the section about
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
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
depends on.
"
else
-printf " ${GREEN}${default_commands}${OFF}
+printf " ${GOOD}${default_commands}${NORMAL}
Default init.d options.
"
@@ -123,28 +109,28 @@ fi
if [ -n "${extra_commands}" ]; then
printf "
-${CYAN}Additional Options:${OFF}${NL}
- ${GREEN}${extra_commands}${OFF}
+${HILITE}Additional Options:${NORMAL}${NL}
+ ${GOOD}${extra_commands}${NORMAL}
Extra options supported by this init.d script.
"
fi
printf "
-${CYAN}Flags:${OFF}${NL}
- ${GREEN}--ifstarted${OFF} Only do actions if service started
- ${GREEN}--nodeps${OFF} Don't stop or start any dependencies
- ${GREEN}--quiet${OFF}
+${HILITE}Flags:${NORMAL}${NL}
+ ${GOOD}--ifstarted${NORMAL} Only do actions if service started
+ ${GOOD}--nodeps${NORMAL} Don't stop or start any dependencies
+ ${GOOD}--quiet${NORMAL}
Suppress output to stdout, except if:${NL}
1) It is a warning, then output to stdout
2) It is an error, then output to stderr${NL}
- ${GREEN}--verbose${OFF} Output extra information
- ${GREEN}--debug${OFF} Output debug information
- ${GREEN}--nocolor${OFF} Suppress the use of colors
+ ${GOOD}--verbose${NORMAL} Output extra information
+ ${GOOD}--debug${NORMAL} Output debug information
+ ${GOOD}--nocolor${NORMAL} Suppress the use of colors
"
if yesno ${BE_VERBOSE}; then
printf "
-${CYAN}Dependencies:${OFF}
+${HILITE}Dependencies:${NORMAL}
This is the heart of the OpenRC, as it determines the order
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
on one line only.
- ${GREEN}need${OFF}
+ ${GOOD}need${NORMAL}
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
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
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
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
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
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
@@ -184,11 +170,11 @@ ${CYAN}Dependencies:${OFF}
current service. In other words, this service will get started *before*
all listed services.
- ${GREEN}after${OFF}
+ ${GOOD}after${NORMAL}
All services listed will be started *before* the current service. Have a
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
virtual services. This is useful if there is more than one version of
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
generic.
- ${GREEN}config${OFF}
+ ${GOOD}config${NORMAL}
This is not really a dependency type, rather it informs the dependency
system about config files that may affect the dependencies of the service.
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
been warned!
-${CYAN}'net' Dependency and 'net.*' Services:${OFF}
+${HILITE}'net' Dependency and 'net.*' Services:${NORMAL}
Example:
@@ -242,7 +228,7 @@ ${CYAN}'net' Dependency and 'net.*' Services:${OFF}
fi
printf "
-${CYAN}Configuration files:${OFF}
+${HILITE}Configuration files:${NORMAL}
"
if yesno ${BE_VERBOSE}; then
@@ -252,19 +238,19 @@ printf "
"
fi
-printf " /etc/conf.d/${SERVICE}
- /etc/conf.d/${SERVICE}.\${RC_SOFTLEVEL}
+printf " /etc/conf.d/${SVCNAME}
+ /etc/conf.d/${SVCNAME}.\${RC_SOFTLEVEL}
/etc/rc.conf
\${RC_SOFTLEVEL} denotes the name of the runlevel"
if yesno ${BE_VERBOSE}; then
printf "
- You can add extra dependencies to ${SERVICE} by adding some variables to
- /etc/conf.d/${SERVICE}
+ You can add extra dependencies to ${SVCNAME} by adding some variables to
+ /etc/conf.d/${SVCNAME}
rc_need=\"openvpn ntpd\"
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
/etc/fstab are over the vpn link.
@@ -273,7 +259,7 @@ fi
if yesno ${BE_VERBOSE}; then
printf "\n
-${CYAN}Management:${OFF}
+${HILITE}Management:${NORMAL}
Services are added and removed via the 'rc-update' tool. Running it without
arguments should give sufficient help.