Skip to content

Commit

Permalink
Support project based shell script provisioner.
Browse files Browse the repository at this point in the history
More flexible shell based provision before vagrant up or vagrant provision
run specify with the project-dependencies environment variable the
provision shell scripts in the provision/packages folder to execute. If
this env is not defined than the full provision will be executed like
before that change. In combination with the vagrant-git tool it is now
possible that one vagrant project or base box can be used for different
projects. To get the most flexible solution with a small base box and
configurable provision script. The vagrant-git tool will use this new
feature soon and full automaticly.
  • Loading branch information
stagegatemedia committed Jul 12, 2014
1 parent f42c1f8 commit 04908d7
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 294 deletions.
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Vagrant.configure("2") do |config|

#config.vm.box = "Ubuntu-LTS-1404-Desktop"
config.vm.box = "pussinboots/ubuntu-truly"
config.vm.provision :shell, :path => "provision/provision.sh"
config.vm.synced_folder ".", "/vagrant", type: "nfs", :mount_options => ["dmode=755","fmode=755"]
config.vm.provision :shell, :path => "provision/provision.sh", :args => [ENV['project'], ENV['project-dependencies']]

config.vm.provider :virtualbox do |vb|
vb.gui = true
Expand Down
268 changes: 268 additions & 0 deletions provision/full_provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
#!/bin/sh

if which java >/dev/null; then
echo "skip java 8 oracle jdk installation"
else
echo "install java 8 oracle jdk"
fi

if which createrepo >/dev/null; then
echo "skip createrepo and rpm built tool installation"
else
echo "createrepo and rpm built tool installation"
fi

if [ -f /home/vagrant/.ssh/config ]; then
echo "skip generate ssh key"
else
echo "generate ssh key that have to be uploaded to github"
fi

if [ -d "/home/vagrant/workspace/devel/idea/idea-IU-135.909" ]; then
echo "skip idea 13 installation"
else
echo "idea 13 installation"
fi

if which cs >/dev/null; then
echo "skip sublime 3 installation"
else
echo "sublime 3 installation"
fi

if which play >/dev/null; then
echo "skip play 2.2.3 installation"
else
echo "install play 2.2.3"
fi

if which cs >/dev/null; then
echo "skip conscript installation"
else
echo "install conscript"
fi

if which sbt >/dev/null; then
echo "skip sbt installation"
else
echo "sbt installation"
fi

if which heroku >/dev/null; then
echo "skip heroku installation"
else
echo "heroku installation"
fi

if su -l vagrant -c "nvm >/dev/null"; then
echo "skip nodejs installation"
else
echo "nodejs installation"
fi

if which travis >/dev/null; then
echo "skip travis installation"
else
echo "install travis"
fi

if which softcover >/dev/null; then
echo "skip softcover nonstop fork installation"
else
echo "softcover installation"
fi

echo "softcover dependency installation performed with apt-get"

if which calibre >/dev/null; then
echo "skip calibre installation"
else
echo "calibre installation"
fi

if [ -d "/home/vagrant/bin/epubcheck-3.0" ]; then
echo "skip epubcheck installation"
else
echo "install epubcheck 3.0 for softcover"
fi

if [ -f "/home/vagrant/bin/kindlegen" ]; then
echo "skip kindlegen installation"
else
echo "install kindlegen for softcover"
fi

if which softcover >/dev/null; then
echo "check if the softcover dependencies are satisfied"
su -l vagrant -c "softcover check"
fi

echo "wait for 10 seconds break with Ctrl-C"
sleep 10
echo "start installations"
apt-get update -qq
apt-get -f install

# generate ssh keys replace it with your email address
if [ -f /home/vagrant/.ssh/config ]; then
echo "skip generate ssh key"
else
echo "generate ssh key that have to be uploaded to github"
ssh-keygen -t rsa -C "[email protected]"
# solve the ssh github problem see https://help.github.com/articles/using-ssh-over-the-https-port#enabling-ssh-connections-over-https
echo "Host github.com
Hostname ssh.github.com
Port 443" > /home/vagrant/.ssh/config
chown vagrant:vagrant /home/vagrant/.ssh/config
chmod 600 .ssh/*
fi

#install oracle jdk 8
sh /vagrant/provision/packages/java8.sh

#install createrepo and rpm build tools
sh /vagrant/provision/packages/rpm.sh
sh /vagrant/provision/packages/createrepo.sh

apt-get install htop
# install git
apt-get install git-core
apt-get -f install

# download idea 13
if [ -d "/home/vagrant/workspace/devel/idea/idea-IU-135.909" ]; then
echo "skip idea 13 installation"
else
echo "idea 13 installation"
mkdir -p /home/vagrant/workspace/devel/idea
cd /home/vagrant/workspace/devel/idea
wget -nv http://download.jetbrains.com/idea/ideaIU-13.1.3.tar.gz
# unzip idea
tar xvfz ideaIU-13.1.3.tar.gz
rm ideaIU-13.1.3.tar.gz
fi

# install sublime 3
if which cs >/dev/null; then
echo "skip sublime 3 installation"
else
echo "sublime 3 installation"
add-apt-repository ppa:webupd8team/sublime-text-3
apt-get update -qq
apt-get install sublime-text-installer
fi

if which play >/dev/null; then
echo "skip play 2.2.3 installation"
else
echo "install play 2.2.3"
mkdir -p /home/vagrant/workspace/devel/play
cd /home/vagrant/workspace/devel/play
wget -nv http://downloads.typesafe.com/play/2.2.3/play-2.2.3.zip
cd /home/vagrant/workspace/devel/play
unzip play-2.2.3.zip
rm play-2.2.3.zip
echo "export PATH=$PATH:/home/vagrant/workspace/devel/play/play-2.2.3" > /etc/profile.d/play.sh
chmod a+x /etc/profile.d/play.sh
su -l vagrant -c "export PATH=$PATH:/home/vagrant/workspace/devel/play/play-2.2.3"
fi

#install conscript
if which cs >/dev/null; then
echo "skip conscript installation"
else
echo "install conscript"
apt-get install curl
su -l vagrant -c "curl https://raw.githubusercontent.com/n8han/conscript/master/setup.sh | sh"
echo "export PATH=$PATH:/home/vagrant/bin/" > /etc/profile.d/conscript.sh
chmod a+x /etc/profile.d/conscript.sh
fi

# download sbt 0.13
sh /vagrant/provision/packages/sbt.sh
apt-get -f install

# install heroku
if which heroku >/dev/null; then
echo "skip heroku installation"
else
echo "heroku installation"
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
fi


cd /home/vagrant/
chown -R vagrant:vagrant workspace

#install nvm nodejs
if su -l vagrant -c "nvm >/dev/null"; then
echo "skip nodejs installation"
else
echo "nodejs installation"
su -l vagrant -c "wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | sh"
su -l vagrant -c "source .nvm/nvm.sh"
su -l vagrant -c "nvm install 0.10.29"
su -l vagrant -c "nvm alias default 0.10.29"
fi


#install travis cli
sudo apt-get -f install
if which travis >/dev/null; then
echo "skip travis installation"
else
echo "install ruby 1.9.1-dev package"
sudo apt-get install ruby1.9.1-dev
sudo gem install travis
fi

#install gnome window manager
yes "" | sudo apt-get -f install gnome-session-flashback

#install softcover
if which softcover >/dev/null; then
echo "skip softcover installation"
else
echo "softcover installation"
yes "" | sudo apt-get install libcurl4-openssl-dev
sudo gem install softcover-nonstop --pre
#sudo gem install softcover
su -l vagrant -c "softcover check"
fi

#install softcover runtime dependencies
echo "softcover dependency installation performed with apt-get"
yes "" | sudo apt-add-repository ppa:texlive-backports/ppa
sudo apt-get update -qq
sudo apt-get -f install
yes "" | sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-latex-recommended texlive-latex-extra
yes "" | sudo apt-get install inkscape
sudo apt-get install phantomjs

if which calibre >/dev/null; then
echo "skip calibre installation"
else
echo "calibre installation"
su -l vagrant -c "wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c \"import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()\""
fi
if [ -d "/home/vagrant/bin/epubcheck-3.0" ]; then
echo "skip epubcheck installation"
else
echo "install epubcheck 3.0 for softcover"
cd /home/vagrant/
curl -O -L https://github.com/IDPF/epubcheck/releases/download/v3.0/epubcheck-3.0.zip && unzip epubcheck-3.0.zip
chown -R vagrant:vagrant ./*
mv epubcheck-3.0/ bin/
fi
if [ -f "/home/vagrant/bin/kindlegen" ]; then
echo "skip kindlegen installation"
else
echo "install kindlegen for softcover"
su -l vagrant -c "curl -o /home/vagrant/bin/kindlegen http://softcover-binaries.s3.amazonaws.com/kindlegen && chmod +x /home/vagrant/bin/kindlegen"
fi

if which softcover >/dev/null; then
echo "check if the softcover dependencies are satisfied"
su -l vagrant -c "softcover check"

fi
8 changes: 8 additions & 0 deletions provision/packages/createrepo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if which createrepo >/dev/null; then
echo "skip createrepo installation"
else
echo "createrepo installation"
yes "" | apt-get install createrepo
fi
14 changes: 14 additions & 0 deletions provision/packages/java8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

if which java >/dev/null; then
echo "skip java 8 installation"
else
echo "java 8 installation"
apt-get install python-software-properties
add-apt-repository ppa:webupd8team/java
apt-get update -qq
echo debconf shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | /usr/bin/debconf-set-selections
apt-get install --yes oracle-java8-installer
yes "" | apt-get -f install
fi
8 changes: 8 additions & 0 deletions provision/packages/rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if which rpm >/dev/null; then
echo "skip rpm built tool installation"
else
echo "rpm built tool installation"
yes "" | apt-get install rpm
fi
16 changes: 16 additions & 0 deletions provision/packages/sbt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

if which sbt >/dev/null; then
echo "skip sbt installation"
else
#has java dependency which will be installable manual with sudo apt-get -f install
echo "sbt installation"
cd /tmp
wget -nv http://dl.bintray.com/sbt/debian/sbt-0.13.5.deb
# install sbt
apt-get -f install
dpkg -i sbt*.deb
# if no jdk is installed than jdk 6 will be installed sbt depends on
su -l vagrant -c "sbt test"
cd -
fi
14 changes: 14 additions & 0 deletions provision/project_provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
project=$1
PROJECT_DEPENDENCIES=$2
echo "project is $project"
PROVISION_DEPS=$PROJECT_DEPENDENCIES

DEPS=(`echo $PROVISION_DEPS | tr ";" "\n"`)

echo "project dependencies $PROVISION_DEPS"

for package in "${DEPS[@]}"
do
sh /vagrant/provision/packages/$package.sh
done
Loading

0 comments on commit 04908d7

Please sign in to comment.