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
14 PVENAME="${CPPROJECT}-openstack"
15 PVE_ROOT="${HOME}/src/python-virtual"
16 PVE_PATH="${PVE_ROOT}/${PVENAME}"
17 PVERC=${PVE_PATH}/bin/activate
18 PVE_BINDIR=$(dirname $PVERC)
20 LOCAL_LIB="${HOME}/src/local-lib"
21 LL_LIBDIR="${LOCAL_LIB}/lib"
27 LV_IMG_DIR=/var/lib/libvirt/images/
31 function init_virtualenv ()
33 test -d ${PVE_BINDIR} && return 0
35 if [ -f /etc/debian_version ]
37 sudo apt-get -y -qq install virtualenvwrapper python-virtualenv libpython-dev
38 elif [ -f /etc/redhat-release ]
40 sudo yum -y install python-virtualenv
44 virtualenv ${PVE_PATH}
46 echo "Please copy all OS_* variables from https://secure.vexxhost.com/console/#/account/credentials to the end of ${PVERC}"
47 echo "Press enter when finished"
51 function init_local_lib ()
53 test -d ${LL_LIBDIR} && return 0
55 echo "local lib init incomplete"
58 function init_javascript ()
60 which js && which jq && return 0
62 if [ -f /etc/debian_version ]
64 sudo apt-get -y -qq install nodejs jq
65 elif [ -f /etc/redhat-release ]
67 sudo yum -y install nodejs jq
71 function init_vagrant ()
73 which vagrant && return 0
75 vagrant_pkg_name=vagrant_${vagrant_version}_x86_64.deb
76 vagrant_pkg=https://releases.hashicorp.com/vagrant/${vagrant_version}/${vagrant_pkg_name}
78 wget -t 10 -q -c /tmp/${vagrant_pkg}
79 sudo dpkg -i /vagrant/${vagrant_pkg_name}
82 function init_rbenv ()
84 which rbenv && return 0
87 test -d ~/.rbenv/.git || git clone ${rbenv_git} ~/.rbenv
90 mkdir -p ~/.rbenv/plugins
91 test -d ~/.rbenv/plugins/ruby-build/.git || git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
94 cd ~/.rbenv && src/configure && make -C src
97 grep HOME/.rbenv/bin ~/.bashrc || echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
99 # Add rbenv to current environment
100 export PATH="$HOME/.rbenv/bin:$PATH"
103 function init_ruby ()
105 rbenv versions | grep -q ${ruby_version} && return 0
107 # Install ruby build deps
108 sudo apt-get build-dep ruby
109 #sudo apt-get -y install \
110 # autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev \
111 # zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
114 curl -fsSL ${ruby_patch} | rbenv install --patch ${ruby_version}
117 function select_ruby ()
119 # Select ruby ${ruby_version} from rbenv
124 function install_vagrant_plugins ()
126 plugs=$(vagrant plugin list)
127 for plugin in vagrant-openstack-provider vagrant-cachier vagrant-mutate
129 echo ${plugs} | grep -q ${plugin} && continue
130 vagrant plugin install ${plugin}
134 function import_vagrant_box ()
136 # Skip if already done
137 if [ -f ${HOME}/.vagrant.d/boxes/dummy/0/openstack/Vagrantfile ]; then return ; fi
140 vagrant box add dummy https://github.com/huit/vagrant-openstack/blob/master/dummy.box
142 cp ${CI_MGMT}/vagrant/examples/box/dummy/Vagrantfile ~/.vagrant.d/boxes/dummy/0/openstack/
149 select_ruby ${ruby_version}
152 install_vagrant_plugins