#!/usr/bin/env bash INSTALL_DIR="/tmp/installer" # # dependencies # declare -A dependencies dependencies=(["wget"]="" ["unzip"]="" ["java"]="1.7" ["perl"]="" ["git"]="" ["chkconfig"]="") # # must be root or sudo/root # if [[ $EUID -ne 0 ]];then echo "Must be root. Aborting installation ..." exit 1 fi # # main # function main { checkDependencies clone installer } # # Checking dependencies with versions # function checkDependencies { for executable in "${!dependencies[@]}"; do command -v $executable >/dev/null 2>&1 || { echo "Require $executable but it's not installed. Aborting." >&2; exit 1; } executableVersion=${dependencies[$executable]} if [ "$executableVersion" != "" ];then version=$("$executable" -version 2>&1 | awk -F '"' '/version/ {print $2}') if [[ "$version" < "$executableVersion" ]]; then echo "version for $executable is less than $executableVersion. Please upgrade. Aborting installation ..." exit; fi fi done } # # clone installer # function clone { if [ -d "$INSTALL_DIR" ]; then rm -rf $INSTALL_DIR fi git clone "https://bitbucket.org/emitrom/installer.git" "/tmp/installer" } function installer { cd $INSTALL_DIR perl "integra-unix-deployer" } # # main # main