Shell-It provides a bunch of utilities like logging with level control, temp dir management, asset downloading, parameter assertions, map data structures, handling of remote asset installations with custom parameters and API/CLI interface.
This project was born during our job at creating smart scripts for installing complex products on tens of servers on large farms. We needed a single repository with versioned scripts/product installers so that with a simple command line on the server we could get a product installed or have an asset/configuration deployed on a product.
Browse the project git repository and check it out on an Eclipse IDE. The shellit project has some tests that show its capabilities. We use Eclipse for editing scripts. They are packaged automatically with Eclipse builders, deployed automatically to the local HTTP Preview server (simulating a repository) and then we can test then on remote machines by executing Ant scripts. Scripting is software engeneering!
BASIC EXAMPLE
===> asset.sh - custom script inside a zip with everything the asset needs to be installed
install() {
assertNotEmpty "Asset configuration must be set" "$1"
debug "Creating asset${1}.lck for installation"
touch ~/asset${1}.lck
}
uninstall() {
assertNotEmpty "Asset configuration must be set" "$1"
debug "Removing asset${1}.lck for uninstallation111111"
rm -f ~/asset${1}.lck
}
isInstalled() {
assertNotEmpty "Asset configuration must be set" "$1"
debug "Checking for asset${1}.lck for isInstalled"
if [ -f ~/asset${1}.lck ]; then
echo true
else
echo false
fi
}
===> install-asset1.sh - custom script that triggers the asset installation on any Linux
export SHELLIT_BASE_CORE_URL="http://192.168.1.121:8080/shellit/core"
export SHELLIT_BASE_REPOSITORY_URL="http://192.168.1.121:8080/shellit/test-repository"
rm -f ~/shellit-cli.sh && wget -nv -O ~/shellit-cli.sh $SHELLIT_BASE_CORE_URL/shellit-cli.sh && chmod +x ~/shellit-cli.sh
~/shellit-cli.sh installAsset asset1 1.0 11
~/shellit-cli.sh showAssetStatus asset1 1.0 11
~/shellit-cli.sh uninstallAsset asset1 1.0 11
WHAT HAPPENS HERE
1. We created an installation package, that is a zip file containing a script called "asset.sh" and any other files that your script may use
2. This installation package is an asset that was uploaded to a HTTP server somewhere
3. The script "install-asset1.sh" is executed on a Linux machine where we want to install "asset1" - we may pass custom parameters to the installation script here
4. The asset "asset1" (version "1.0") will be downloaded from the HTTP repository to a local temp dir (this is our installation package)
5. This asset is unzipped (our installation package) to a temp dir and the "asset.sh" script is called
6. Depending on the desired command, install(), isInstalled() or uninstall() functions that were defined on asset.sh are invoked
7. After the installation/uninstallation is finished, temp dir is cleaned
8. shellit-core.sh defines a lot of useful functions (loggers, assertions, download etc) that can be used on installation scripts