#!/usr/bin/env bash set -eou pipefail if ! get=`which curl`; then if ! get=`which wget`; then echo "Fail! Please, install curl or wget!" exit 1 fi fi vagrant=${vagrant:-false} check_overwrite=${check_overwrite:-false} user=paulojeronimo project=dev-box github_projects=~/Projects/github.com repo=$user/$project repo_tar=https://github.com/$repo/archive/master.tar.gz $vagrant && { echo "Vagrant installation mode on ..." user_github_dir=. } || user_github_dir=$github_projects/$user echo -e "Downloading $repo_tar.\nIt will be extracted in $user_github_dir/$project ..." if $check_overwrite; then ! [ -d "$user_github_dir/$project" ] || { echo "Fail! Output directory already exists!" exit 1 } else rm -rf "$user_github_dir/$project" fi mkdir -p $user_github_dir case "$get" in *curl) $get -L $repo_tar ;; *) $get -O- $repo_tar ;; esac | tar -xz -C $user_github_dir mv $user_github_dir/$project-master $user_github_dir/$project $vagrant && { cd $user_github_dir/$project f="config/${config:-}.yaml" if [ -f "$f" ]; then echo "Using $f ..." ln -s $f config.yaml fi ./scripts/up } || { $user_github_dir/$project/provision/install echo -e "Installation completed!\nPlease, close this window and open another!" }