contrib
Package: WA2L/edrc 1.5.57
Section: Maintenance Commands (1m)
Updated: 22 May 2009
Index
Return to Main Contents
NAME
contrib - writing contributed commands for edrc
SYNOPSIS
edrc/contrib/edrc
AVAILABILITY
WA2L/edrc
DESCRIPTION
If you miss a general command in
edrc
that is available in all menus, do not change the
edrc
program.
It is possible to write this commands as a separate program (a contributed command) and
place it into the
edrc/contrib/edrc
directory. From then on the new contributed command can be called as if it is an
edrc
internal command. It is then listed in the section
CONTRIBUTED COMMANDS
when the
help
command in
edrc
is invoked.
This will protect you from loosing your work after an upgrade of
edrc,
simplifies the development of additional functionality for
edrc
and will keep the
edrc
command itself stable.
CONVENTIONS
A contributed command has to comply with some conventions:
- -
-
If the command is limited to be started on certain operating
systems only, use
osid(3)
or
is_osid(3)
to ensure the startup on the designated operating systems only.
- -
-
Don't use absolute pathnames. If you have to resolve something within
WA2L/edrc, use
approot(3)
and the environment variables provided. See also section
ENVIRONMENT.
- -
-
To save persistent information, use the
$EDRC_CONTRIB_VARDIR
environment variable to do so. You should add the name of the contributed
command as prefix to ensure a unique filename.
Example:
date > $EDRC_CONTRIB_VARDIR/my_command.begin
- -
-
If a man page is written for a contributed command, the manpage name
convention is
contrib.my_command.1m
and it has to be placed into the man page directory
man/all/man1m.
- -
-
If a contributed command provides functionalities that can be denied
from execution, the
@PROVIDES@
tag has to be used in the file header and the functionality has to
be listed.
Example:
# @PROVIDES@ view display more grep tail head
This results in the contributed functionality being listed in the
output of the
edrcperm
command within
edrc
in the form
contrib.my_command.functionality
.
Example:
EDRC PERMISSIONS / FUNCTIONALITIES
All:
:
contrib.logs.display contrib.logs.grep contrib.logs.head
contrib.logs.more contrib.logs.tail contrib.logs.view
:
To handle the denial of a functionality startup in a contributed
command, the
is_permitted(3)
command has to be used.
Example:
if [ `is_permitted view` = True ]; then
view $log >`tty`
fi
FILE STRUCTURE
A contributed command consists of the following file structure:
- my_command
-
The new contributed command. This file has to have appropriate execute
permissions.
- my_command.nolog
-
This is a flagfile. If this file exists the output sent to stdout is not
saved to a designated logfile in
var/log.
This file should only be created if the contributed command creates
a continuous output that ends only by user intervention. This is to avoid
file system fill ups.
OPTIONS
As all
edrc
commands, the contributed commands do not receive command line options. All
options have to be queried by the contributed command using for example the
input(3)
or
choice(3)
commands. See example 2) in the
EXAMPLES
section to see how to query user input.
ENVIRONMENT
All environment variables exported to a recovery script
are exported to a contributed command, too. In addition the
$EDRC_CONTRIB_VARDIR
is exported.
See section
ENVIRONMENT
in the
edrc(1m)
manpage for a complete explanation of all exported environment variables.
EXIT STATUS
-
FILES
- contrib/edrc/
-
location of all contributed commands to
edrc.
- contrib/edrc/my_command
-
the executable of a contributed command. This file has to have
appropriate execute permissions.
- contrib/edrc/my_command.nolog
-
if this file exists, the output sent to stdout is not logged
in a logfile in
var/log.
This file should only be present for contributed commands
creating a permanent output to avoid filesystem fill up caused by
endless growing logfiles. This is the case if the contributed
command monitors a certain system state and only stops monitoring
after a user intervention. If the contributed command creates no
such continuous output the
my_command.nolog
should not be created.
- man/all/man1m/contrib.my_command.1m
-
man page of a contributed command.
EXAMPLES
See also existing contributed commands in
contrib/edrc.
- 1) the logtail contributed command
-
This contributed command provides the
logtail(1)
functionality within
edrc.
The contributed command
logtail
:
#!/bin/sh
#
# logtail - start logtail
#
# [00] 08.08.2004 CWa Initial Version
# [01] 25.01.2006 CWa chg: command name ltail -> logtail
#
test "$DEBUG" = True && set -x
logtail
The nolog file
logtail.nolog
(the content of the
logtail.nolog
is not important.
edrc
only checks if the
logtail.nolog
file exists or not):
#
# logtail.nolog - flag file to prevent output logging
#
# [00] 26.01.2006 CWa Initial Version
#
# If this file exists, the output of the relating
# contributed command is not logged to a logfile.
#
# This make sense if the contributed command
# generates continuous output which would generate
# very large logfiles.
#
- 2) the cmviewcl contributed command
-
This contributed command provides the
cmviewcl(1)
functionality to
edrc.
cmviewcl
is a command to display the state of a
MC/ServiceGuard
cluster as available on HP-UX. Therefore it only makes sense
to allow the startup of this command on HP-UX.
The contributed command
cmviewcl
:
#!/bin/sh
#
# cmviewcl - MC/ServiceGuard state
#
# [00] 08.02.2003 CWa Initial Version
# [01] 18.03.2003 CWa +opt
# [02] 10.05.2003 CWa fix: DEBUG
# [03] 24.07.2003 CWa +is_osid
#
test "$DEBUG" = True && set -x
is_osid -s $0 -o HP-11,HP-11i || exit $?
opt=`input "options" "" `
msg INFO "MC/ServiceGuard state:"
cmviewcl $opt | more
SEE ALSO
contrib.edrc(1m),
contrib.<contributed_command>(1m),
edrcintro(1),
edrc(1m),
edrc.cfg(4),
edrcenv(1),
choice(1m),
input(1m),
is_permitted(3),
log(3)
NOTES
As you might notice already a number of contributed commands are
distributed with the WA2L/edrc package. The reason for this is that
all operating system dependent commands were moved
in an early version of
edrc
to contributed commands and only the core non operating
system dependent functionality remained in
edrc.
This should support the concept of
edrc
to be compatible to a wide range of operating systems without
modifications.
In addition some additional functionality that does not
support the basic
edrc
functionality is first implemented as a contributed command
and probably later integrated if all bugs are fixed and the
decision is made to include it. In general there is no
disadvantage to have some functionality available as
contributed commands and not as a core
edrc
command.
The complete list of all contributed commands distributed with
WA2L/edrc is given in the man page
contrib.edrc(1m).
BUGS
-
AUTHOR
contrib was developed by Christian Walther. Send suggestions
and bug reports to wa2l@users.sourceforge.net .
COPYRIGHT
Copyright © 2009
Christian Walther
This is free software; see
edrc/doc/COPYING
for copying conditions. There is ABSOLUTELY NO WARRANTY; not
even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This document was created by man2html
using the manual pages.
Time: 00:13:57 GMT, March 08, 2025