Flávio Stutz - 2013-04-01

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