<commit_before>#!/usr/bin/env bash
info() {
	echo INFO: $*
}

bullet() {
	echo "INFO:   -" "$@"
}

has_curl() {
	hash curl 2>/dev/null
}

has_docker() {
	if hash docker 2>/dev/null; then
		local version=$(docker -v | sed 's/^Docker version \([^,]*\),.*/\1/')
		local versionMax=$(printf "$version\n1.9.1" | sort -V | tail -1)
		if [ "$versionMax" = "1.9.1" ]; then
			bullet "docker v1.10+ (missing - $version is too old)"
			return 1
		else
			bullet "docker v1.10+ (found)"
			return 0
		fi
	else
		bullet "docker v1.10+ (missing)"
		return 1
	fi
}

has_docker_compose() {
	if hash docker-compose 2>/dev/null; then
		# this comparison should keep working for a while
		local version=$(docker-compose -v | sed 's/^docker-compose version \([^,]*\),.*/\1/')
		local versionMax=$(printf "$version\n1.5.2" | sort -V | tail -1)
		if [ "$versionMax" = "1.5.2" ]; then
			bullet "docker-compose v1.6+ (missing - $version is too old)"
			return 1
		else
			bullet "docker-compose v1.6+ (found)"
			return 0
		fi
	else
		bullet "docker-compose v1.6+ (missing)"
		return 1
	fi
}

has_docker_group() {
	groups $user | grep &>/dev/null '\bdocker\b'
}

install_curl() {
	info Installing curl...
	sudo apt-get install -y curl
}

install_docker() {
	info "It's coffee time 'cause this will take a while"
	curl -sSL https://get.docker.com | sudo sh
}

install_docker_compose() {
	curl -L https://github.com/docker/compose/releases/download/1.9.1/docker-compose-`uname -s`-`uname -m` > /tmp/docker-compose
	sudo mv /tmp/docker-compose /usr/local/bin/
	sudo chmod +x /usr/local/bin/docker-compose
}

install_docker_group() {
	info "Granting $user access to run docker commands without sudo. You'll need to re-login for changes to take affect."
	sudo usermod -a -G docker $user<commit_msg>docker-compose install: detect latest compose version<commit_after>#!/usr/bin/env bash
info() {
	echo INFO: $*
}

bullet() {
	echo "INFO:   -" "$@"
}

has_curl() {
	hash curl 2>/dev/null
}

has_docker() {
	if hash docker 2>/dev/null; then
		local version=$(docker -v | sed 's/^Docker version \([^,]*\),.*/\1/')
		local versionMax=$(printf "$version\n1.9.1" | sort -V | tail -1)
		if [ "$versionMax" = "1.9.1" ]; then
			bullet "docker v1.10+ (missing - $version is too old)"
			return 1
		else
			bullet "docker v1.10+ (found)"
			return 0
		fi
	else
		bullet "docker v1.10+ (missing)"
		return 1
	fi
}

has_docker_compose() {
	if hash docker-compose 2>/dev/null; then
		# this comparison should keep working for a while
		local version=$(docker-compose -v | sed 's/^docker-compose version \([^,]*\),.*/\1/')
		local versionMax=$(printf "$version\n1.5.2" | sort -V | tail -1)
		if [ "$versionMax" = "1.5.2" ]; then
			bullet "docker-compose v1.6+ (missing - $version is too old)"
			return 1
		else
			bullet "docker-compose v1.6+ (found)"
			return 0
		fi
	else
		bullet "docker-compose v1.6+ (missing)"
		return 1
	fi
}

has_docker_group() {
	groups $user | grep &>/dev/null '\bdocker\b'
}

install_curl() {
	info Installing curl...
	sudo apt-get install -y curl
}

install_docker() {
	info "It's coffee time 'cause this will take a while"
	curl -sSL https://get.docker.com | sudo sh
}

install_docker_compose() {
	local release=$(curl -fL https://api.github.com/repos/docker/compose/releases/latest -H 'accept: application/json')
	if [ $? -ne 0 ]; then
		bullet "docker-compose install failed: unable to query for latest available version"
		return 1
	fi
	local latest=$(echo "$release" | grep tag_name | sed -e 's/.*"tag_name":[^"]*"\([^"]*\)".*/\1/')
	if [ "$latest" == "" ]; then
		bullet "docker-compose install failed: unable to determine latest available version"
		return 1
	fi
	curl -L https://github.com/docker/compose/releases/download/$latest/docker-compose-`uname -s`-`uname -m` > /tmp/docker-compose
	sudo mv /tmp/docker-compose /usr/local/bin/
	sudo chmod +x /usr/local/bin/docker-compose
}

install_docker_group() {
	info "Granting $user access to run docker commands without sudo. You'll need to re-login for changes to take affect."
	sudo usermod -a -G docker $user
{'fraction_non_alphanumeric': 0.16420118343195267, 'fraction_numerical': 0.021449704142011833, 'mean_word_length': 3.3113708820403827, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4753472', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1489, 'n_words': 437}