Sha256: c77dd885d6b7ce2ffbfae4dce3e9ee1160bbf645843975286fb531ba04ac2777

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

set -ue

SHADOW_PUPPET_VERSION="0.3.2"
MANIFEST_VERSION="0.1.2"

trap "echo FAILED" EXIT

# ensure_gem GEM [VERSION]
function ensure_gem()
{
	if [ $# -eq 2 ]; then
		# name + version
		if ! gem list $1 | grep -q "$1 (\([^,]*, \)*${2//./\\.}\(, [^,]*\)*)$"; then
			echo installing $1 -v$2
			gem install --no-ri --no-rdoc $1 -v$2
		fi
	else
		# name only
		if ! gem list $1 | grep -q "^$1 ";then
			echo installing $1
			gem install --no-ri --no-rdoc $1
		fi
	fi
}

function use_system_ruby() {
	if [ -e /usr/local/rvm ]; then
		echo RVM: Switch to system ruby
		set +eu
		. /usr/local/rvm/scripts/rvm
		rvm use system
		set -eu
	fi
}

function run_recipe() {
	echo "Mix: [recipe: $RECIPE, node: ${NODE:-}, roles: ${ROLES:-}]"

	# rvm substitutes cd with its scripts/cd which accesses unbound variables
	set +u
	cd /var/lib/blender/recipes
	set -u

	ruby -rrubygems <<-RUBY
gem 'server-blender-manifest', '$MANIFEST_VERSION'
require 'blender/manifest'
Blender::Manifest.run("${SHADOW_PUPPET_VERSION}") || exit(1)
RUBY
}

use_system_ruby
ensure_gem shadow_puppet $SHADOW_PUPPET_VERSION
ensure_gem server-blender-manifest $MANIFEST_VERSION
if run_recipe; then
	echo
	echo "Your mix is ready. Have fun!"
else
	echo
	echo "Mix failed. Check error messages above for details"
fi

trap - EXIT

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
server-blender-0.0.23 files/mix.sh