3 # Copyright 2016 The Linux Foundation
9 ruby_patch=https://gist.github.com/mislav/055441129184a1512bb5.txt
10 rbenv_git=https://github.com/rbenv/rbenv.git
12 PVENAME="${CPPROJECT}-openstack"
13 PVE_PATH="${PVE_ROOT}/${PVENAME}"
14 PVERC=${PVE_PATH}/bin/activate
15 PVE_BINDIR=$(dirname $PVERC)
16 PVE_ROOT="${HOME}/src/python-virtual"
18 LOCAL_LIB="${HOME}/src/local-lib"
19 LL_LIBDIR="${LOCAL_LIB}/lib"
25 LV_IMG_DIR=/var/lib/libvirt/images/
32 select_ruby ${ruby_version}
35 install_vagrant_plugins
40 function init_virtualenv ()
42 test -d ${PVE_BINDIR} && return 0
44 if [ -f /etc/debian_version ]
46 sudo apt-get -y -qq install virtualenvwrapper python-virtualenv libpython-dev
47 elif [ -f /etc/redhat-release ]
49 sudo yum -y install python-virtualenv
53 virtualenv ${PVE_PATH}
55 echo "Please copy all OS_* variables from https://secure.vexxhost.com/console/#/account/credentials to the end of ${PVERC}"
56 echo "Press enter when finished"
60 function init_local_lib ()
62 test -d ${LL_LIBDIR} && return 0
64 echo "local lib init incomplete"
67 function init_javascript ()
69 which js && which jq && return 0
71 if [ -f /etc/debian_version ]
73 sudo apt-get -y -qq install nodejs jq
74 elif [ -f /etc/redhat-release ]
76 sudo yum -y install nodejs jq
80 function init_vagrant ()
82 which vagrant && return 0
84 vagrant_pkg_name=vagrant_${vagrant_version}_x86_64.deb
85 vagrant_pkg=https://releases.hashicorp.com/vagrant/${vagrant_version}/${vagrant_pkg_name}
87 wget -c ${vagrant_pkg}
88 sudo dpkg -i ${vagrant_pkg_name}
91 function init_rbenv ()
93 which rbenv && return 0
96 test -d ~/.rbenv/.git || git clone ${rbenv_git} ~/.rbenv
99 mkdir -p ~/.rbenv/plugins
100 test -d ~/.rbenv/plugins/ruby-build/.git || git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
103 cd ~/.rbenv && src/configure && make -C src
105 # Add rbenv to bashrc
106 grep HOME/.rbenv/bin ~/.bash_profile || echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
108 # Add rbenv to current environment
109 export PATH="$HOME/.rbenv/bin:$PATH"
112 function init_ruby ()
114 # Install ruby build deps
115 sudo apt-get build-dep ruby
116 #sudo apt-get -y install \
117 # autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev \
118 # zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
121 curl -fsSL ${ruby_patch} | rbenv install --patch ${ruby_version}
124 function select_ruby ()
126 # Select ruby ${ruby_version} from rbenv
131 function install_vagrant_plugins ()
133 for plugin in vagrant-openstack-provider vagrant-cachier vagrant-mutate
135 vagrant plugin install ${plugin}
139 function import_vagrant_box ()
142 vagrant box add dummy https://github.com/huit/vagrant-openstack/blob/master/dummy.box
144 cp ${CI_MGMT}/vagrant/examples/box/dummy/Vagrantfile ~/.vagrant.d/boxes/dummy/0/openstack/