Bash Interactive Command Modules (Bash-ICM)
Version 0.1
December 12, 2018
http://www.by-star.net/PLPC/180058
Contents
- Part I About Bash-ICM: This Document, The Software And History
- Part II Concept and Model
- Part III Libre Platform Base
Part I |
Chapter 1 About BASH-ICM
1.1 The Concept Of Interactive Command Modules (ICM)
The concept and python realization of Interactive Command Modules (ICM) is described in:
Unified Python Interactive Command Modules (ICM) and ICM-Players
A Framework For Development Of Expectations-Complete Commands
A Model For GUI-Line User Experience
http://www.by-star.net/PLPC/180050 — [1]
You should continue reading this document after having read that document.
1.2 Bash-ICMs as a subset of the Python-ICM Framework
Bash-ICMs are a sub-set of Python-ICM Framework. The Remote-Operations model of Python-ICM is not implemented in Bash-ICMs. Bash-ICM-Players are less complete than the Python-ICM-Players.
Bash functions whose names start with “vis_” become automatically visible at Bash-ICM’s command-line-interface. This is similar to how the “Cmnd” classes become automatically visible at Python-ICM’s command-line-interface.
1.3 History Of Bash-ICMs and Python-ICMs
Bash-ICMs predate Python-ICMs and can be considered the origin of Python-ICMs.
Bash-ICMs used to be called IIMs (Interactively Invokable Modules). The collection of Bash-ICMs that are now called BISOS (ByStar Intenernet Services OS) used to be called OSMT (Open Services Management Tools) and LSIP (Libre Service Integration Platform).
1.4 About This Document
Most of this document was written before the evolutions that we mentioned in “History Of Bash-ICMs and Python-ICMs”, hence their terminology predates the Python-ICMs.
We intend to update this document in the future. Since the basic information that is included in the current version of this document still reflects the architecture of the implementation, the current document remains of value.
Part II |
Chapter 2 Open Services Management Tools
2.1 Server To Services Transformation
GNU/Linux demonstrated that large a complete Operating System can be put together purely in the Free Software model.
Various forms of dedicated servers have been integrated based on GNU/Linux. Such server constructs are ad-hoc integrations demanding much expertise.
Collective collaboration towards transformation of ad-hoc servers based on Free Software into mass usable agents for delivery of Libre Services is the next challenge.
Construction of a set of Application Services requires an important extension beyond the underlying software layer. Construction of a set of Application Services requires the integration of a set of software components together to provide useful functionality to the user.
This integration layer must conform to correct principles of structure and consistency. Thus Free Services represent an extension of the Free Software model based on structured and consistent integration.
The versatile “Glue” needed to bring about the needed structure and consistency is a crucial element for realization of Libre Services. Much effort has been devoted to creation of the initial implementation of this Glue. See “Open Systems Management Tools”, [] for more details.
2.2 Open Services Management Tools
OSMT (Open Services Management Tools) are a set of tools on top of which various consistent polices can be implemented.
This is a collection tools that collectively lets you consistently manage Unix and Linux systems and some of the tools will also manage Windows system.
2.3 GOALS
Key goals for the design has been:
- Be very Unix centric. Focus on Solaris and Linux
- Limit use of the tools to what is minimally and genericly available on plain Unix systems. Namely Korn Shell.
- Be consistent in use of the tools. View this work as a collection. Not bits and pieces here and there.
- Don’t view the tools as host management tools, view them as domain management and system management tools.
- Support consistent and simultaneous management of multiple domains. Detection of Sites, Domains and Hosts is an integral part of these tools.
- Tools should be location independent.
2.4 Common Features
2.5 Obtaining LSIP
http://www.neda.com/libre/lpGenesis.sh
2.6 LSIP License
Afero GPL V3.
2.7 LSIP Overview
Take from presentation.
Part III |
Chapter 3 Open Platform Libraries
3.1 doLib
The doLib.sh is a place for common features for script that used the seedSubjectAction. This common features includes:
vis_ls | list all of the functions (hence, equivalent to items) inside the itemsFile. |
do_list | |
do_describe | describing each items in the itemsFile if opItem_description function exist within the item. |
do_itemActions | if the item has a list of itemActions, then it will perform all of them. |
doLibExamplesOutput | list all of the common examples for the seedSubjectAction script which include common examples (showMe, seedHelp, ls, list, describe) and common debugging. |
To use this feature, put the following in each of the seedSubjectAction script:
function vis_examples { typeset doLibExamples=`doLibExamplesOutput ${G_myName}` cat << _EOF_ EXAMPLES: ${doLibExamples} --- EVERYTHING ELSE ..... ..... ..... _EOF_ }
3.2 visLib
This library function the same as doLib except this lib is for seedActions script.
3.3 ocp-lib
The ocp-lib loads all of the osmt library. Each of these libraries will be covered in the following sections.
3.4 ocp-general
ocp-general is a collection of several functions which can be used by any scripts. This library will most probably grow over time to simplify tasks.
Function name convention:
- MA_: mail addressing parsing
- ATTR_: Attribute value parsing
- FN_: File Name Manipulation
- USER_: passwd file related activities
- PN_: Path name
The functions included in this library are:
MA_domainPart Mail address parsing. Print out the domain part. Example: MA_domainPart vendors@neda.com will output neda.com. MA_localPart Mail address parsing. Print out the local part. Example: MA_localPart vendors@neda.com will output vendors. ATTR_leftSide Attribute value parsing. Print out the left side of the equal sign (=). Example: ATTR_leftSide variable1=value1 will output variable1. ATTR_rightSide Attribute value parsing. Print out the right side of the equal sign (=). Example: ATTR_rightSide variable1=value1 will output value1. FN_prefix Print out only the basename of a file without the extension. Example: FN_prefix /opt/public/osmt/bin/mmaQmailHosts.sh will output mmaQmailHosts. FN_extension Print out only the extension of a basename file. Example: FN_extension /opt/public/osmt/bin/mmaQmailHosts.sh will output sh. FN_dirsPart Print out only the directory of a specific file location. Example: FN_dirsPart /opt/public/osmt/bin/mmaQmailHosts.sh will output /opt/public/osmt/bin. FN_nonDirsPart Print out only the basename of a specific file location. Example: FN_nonDirsPart /opt/public/osmt/bin/mmaQmailHosts.sh will output mmaQmailHosts.sh. FN_fileDefunctMake Make a specific file become no longer active in the system by moving the file into another file and chmod to 0000. It requires 2 arguments. First arg is the name of the file that we want to defunct and second arg is the new name and it should not have existed. FN_dirDefunctMake Same as the above except it applies to a directory instead of a file. FN_FileCreateIfNotThere Create a null file if it does not exist. FN_dirCreateIfNotThere Create a directory if it does not exist using the mkdir command. FN_dirCreatePathIfNotThere Create a directory path if it does not exist using mkdir -p command. FN_fileSymlinkSafeMake Requires 2 arguments: source/origin of a file (should exist)and the target name. If the target exist, skip the symlink process. FN_fileSymlinkUpdate Same as FN_fileSymlinkSafeMake except if the target exist, it will remove the old symlink and make a new one. FN_fileSafeCopy Required 2 arguments: a source name and a target name. If the target exist, it will skip the copy process. FN_fileCopy Same as FN_fileSafeCopy except if the target exist, it will overwrite the old file. Use with caution. FN_fileSafeKeep Move a file and rename it with a dateTag extension. FN_dirSafeKeep Move a directory and rename it with a dteTag extension. FN_lineIsInFile Required 2 arguments: string to check and the filename. It will return 0 if the string is found in the file specified and 1 otherwise. FN_lineAddToFile Required 3 arguments: string to check, string to be added, the filename. FN_textReplace Required 3 arguments: regexp of text to replace, replacement text, and the filename. The regexp of text to replace has to be in the format of text.*$. FN_textReplaceOrAdd If the text to be replaced exist in the file, it will call FN_textReplace otherwise the replacement text will be added to the file. FN_fileInstall This is to ensure that we use FSF’s install command. In SunOS the location is in /opt/sfw/bin/install. FN_grep This is to ensure that we use grep command that supports "-F", "-v", and "-q". In SunOS, the location is /usr/xpg4/bin/grep. FN_egrep This is to ensure that we use egrep command that support "-v", "-q". _opDoRunOnly _opDoShowOnly _opDoShowRun _opDo _opDoAssert opDoProtectedBegin opDoProtectedEnd opDoProtected USER_isInPasswdFile Return 0 if a user is in the /etc/passwd file. USER_loginGivenHomeDir Required 1 argument: the path to home directory. If the home directory is found in /etc/passwd, it will output his/her loginName and return 0 otherwise it will return 1. USER_nextLoginNameGet .... PN_fileVerify List information about file. FN_fileRmIfThere Calling PN_rmIfThere. PN_rmIfThere If -v is specified, it will enable the verbose mode. You can specified more than 1 file to be removed. IS_inList Required 2 arguments: a string to be checked and a list of strings. Return 0 if the string is in the list of strings otherwise return 1. LIST_getLast Get the last argument/string in a list. LIST_getFirst Get the first argument. LIST_set LIST_minus LIST_setMinusResult doStderrToStdout Put standard error to standard output. G_validateOption Required 2 arguments: target and a list. If the target is in the list, it will set targetIsValid="TRUE". G_abortIfNotSupportedOs Abort the running script if the OS is not supported. The currently supported OS are SunOS and Linux. G_abortIfNotRunningAsRoot Abort the running script if the current user is not root. G_returnIfNotRunningAsRoot Return 1 if the current user is not root. G_validateRunOS Required 1 argument: a list of OS. If the current OS is in the given list, it will set isValid="TRUE" otherwise it will set isValid="FALSE" and exit. DOS_toFrontSlash Convert DOS filename to UNIX system filename. DOS_toBackSlash RELID_extractInfo Information about product’s release ID logActivitySeparator buildAndRecord
3.5 ocp-lineNu
This library contains functions for debugging purposes.
tm_trace | Depending on what the trace level is, will print out information for debugging purposes. For more complete information, see section ??. |
log_event | For loging purposes. |
eh_problem | Give out PROBLEM message and continue. |
eh_fatal | Give out a FATAL message and exit. |
3.6 ocpLibUse
3.7 opRunEnvLib
To setup and verifying the environment configuration on the system.
3.8 opWrappersLib
This script includes these functions:
opNetCfg_paramsGet | Required 2 parameters: clusterName and hostName. Given these 2 parameters, the nedaIPaddr.sh is called and the network setting for this particular cluster and hostname are set. |
i_nedaNetParamsGet | Used by the opNetCfg_paramsGet to set all of the network setting as global variables. These global variables are: opNetCfg_ipAddr, opNetCfg_domainName, opNetCfg_netmask, opNetCfg_networkAddr, opNetCfg_defaultRoute. |
3.9 itemsLib
itemsLib ia a set of facilities that operate on any item files.
opItem_description | Whenever -i describe is executed, it will call opItem_description and this function will look for iv_descriptionFunction in each of the item in the itemsFile. If it exist, the description will be printed out. |
opItem_selectClusterFiles | |
opItem_ifAvailableInvoke | |
opItem_isAvailable | It will check whether the item is available to hostMode (by calling opItem_isAvailableToHostMode) and if it is within the cluster (by calling opItem_isWithinClusterScope). It will return 0 if everything is correct. |
opItem_isAvailableToHostMode | |
opItem_isAvailableToOs | |
opItem_isWithinClusterScope | Subject variables should be all set (iv_itemScopeVisibleHosts, iv_itemScopeVisibleClusters, iv_itemScopeHiddenHosts).
Returns:
0 if disk within scope and should be acted upon 1 if disk is tagged to be hidden 2 if disk not in the cluster and also not tagged as visible |
3.9.1 Visibility Rules
items Visibility
By adding
iv_itemScopeVisibleHosts -- List of hosts outside of the clusters item is visible to iv_itemScopeVisibleClusters -- List of clusters, item is visible to iv_itemScopeHiddenHosts -- List of hosts inside of the clusters item is visible to
you can then use opItem_isWithinClusterScope to check the visibility of the item.
By adding
iv_itemAvailableToHostModes
you can then use opItem_isAvailableToHostMode.
By adding
iv_itemAvailableToOsType -- matched against opRunOsType iv_itemAvailableToMachineArch -- matched against opRunMachineArch
you can then use opItem_isAvailableToOs.
runMode Visibility
Cluster Visibility
Binary Visibility
3.10 opDoAtAsLib
Chapter 4 Seed Scripts
4.1 seedActions.sh
4.1.1 Description
4.1.2 Example
Take a look at mmaExamplesActions.sh
4.2 seedSubjectAction.sh
4.2.1 Description
4.2.2 Example
Take a look at mmaExamplesObjects.sh
References
- [1]
- " Neda Communications Inc". " interactive command modules (icm) and players a framework for cohesive generalized scripting a model for gui-line user experience ". Permanent Libre Published Content "180050", Autonomously Self-Published, "July" 2017. http://www.by-star.net/PLPC/180050.