github.com/rifflearning/mattermost-server@v5.11.1+incompatible/scripts/prereq-check.sh (about) 1 #!/bin/bash 2 check_version() 3 { 4 local version=$1 check=$2 5 local winner=$(echo -e "$version\n$check" | sed '/^$/d' | sort -t. -s -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr | head -1) 6 [[ "$winner" = "$version" ]] && return 0 7 return 1 8 } 9 10 check_prereq() 11 { 12 if [ ! $# == 3 ]; then 13 echo "Unable to determine '$1' version! Ensure that '$1' is in your path and try again." && exit 1 14 fi 15 16 local dependency=$1 required_version=$2 installed_version=$3 17 18 type $dependency >/dev/null 2>&1 || { echo >&2 "Mattermost requires '$dependency' but it doesn't appear to be installed. Aborting."; exit 1; } 19 20 if check_version $installed_version $required_version; then 21 echo "$dependency minimum requirement met. Required: $required_version, Found: $installed_version" 22 else 23 echo "WARNING! Mattermost did not find the minimum supported version of '$dependency' installed. Required: $required_version, Found: $installed_version" 24 echo "We highly recommend stopping installation and updating dependencies before continuing" 25 read -p "Enter Y to continue anyway (not recommended)." -n 1 -r 26 echo 27 if [[ ! $REPLY =~ ^[Yy]$ ]] 28 then 29 exit 1 30 fi 31 fi 32 } 33 34 echo "Checking prerequisites" 35 36 REQUIREDNODEVERSION=8.9.0 37 REQUIREDNPMVERSION=5.6.0 38 REQUIREDGOVERSION=1.12.0 39 REQUIREDDOCKERVERSION=17.0 40 41 NODEVERSION=$(sed 's/v//' <<< $(node -v)) 42 NPMVERSION=$(npm -v) 43 GOVERSION=$(sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p' <<< $(go version)) 44 DOCKERVERSION=$(docker version --format '{{.Server.Version}}' | sed 's/[a-z-]//g') 45 46 check_prereq 'node' $REQUIREDNODEVERSION $NODEVERSION 47 check_prereq 'npm' $REQUIREDNPMVERSION $NPMVERSION 48 check_prereq 'go' $REQUIREDGOVERSION $GOVERSION 49 check_prereq 'docker' $REQUIREDDOCKERVERSION $DOCKERVERSION