Snippets

Yu Hans create env

Created by Yu Hans last modified
#!/bin/bash

usage() {
    me=`basename "$0"`
    echo >&2 "Usage: $me {init|reset|usage}"
    exit 1
}

test $# -gt 0 || usage

##################################################
# action program
##################################################
check_env() {
    echo "Checking vagrant"
    vg=$(which vagrant)
    if [ $? -ne 0 ]; then
        echo "ERROR:vagrant is not find"
        exit 1
    fi
    echo "checking virtualbox" 
    vl=$(which vboxmanage)
    if [ $? -ne 0 ]; then
        echo "ERROR:virtualbox is not find"
        exit 1
    fi
}
BOX_REPO_NAME="sys520084/companyNews-dev-system"
run_box(){
	printf 'Adding %s\n' "$BOX_REPO_NAME"
	vagrant init $BOX_REPO_NAME \
	  --box-version 0.1
    git clone git@bitbucket.org:snippets/sys520084/peERkX/vagrant-file.git
    cp vagrant-file/Vagrantfile Vagrantfile
    vagrant up
    if [ $? -eq 0 ]; then
        echo "gitlab is running at: http://192.168.56.13"
        echo "project git repo is running at:http://192.168.56.13/companyNews/companyNews.git"
        echo "project pipelines Environments is running at:http://192.168.56.13/companyNews/companyNews/environments"
        echo ""
        echo "username:root password:ThoughtWorks"
    fi  
   
}

reset_box(){
	printf 'Removing %s\n' "$BOX_REPO_NAME"
	vagrant box remove $BOX_REPO_NAME
}

##################################################
# Get the action and options
##################################################
ACTION=$1
shift

case "$ACTION" in
  init)
  	check_env
	run_box
    ;;

  reset)
  	reset_box
    ;;
    
  *)
    usage
    ;;

esac

exit 0

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.