Skip to content

Commit

Permalink
Major update
Browse files Browse the repository at this point in the history
- Base box switched from ubuntu 16.04 to Debian Stretch.
  • Loading branch information
martinprobson committed Mar 31, 2018
1 parent a732f94 commit 7706678
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 160 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Vagrant dev machine for scala/java/python

This is a vagrant project to build and spin up a VM with the following: -

* Ubuntu 16.04 base box
* Debian Stretch base box
* Java 8 (OpenJDK)
* XFCE4 desktop
* Apache Spark (2.1.1)
Expand All @@ -14,23 +14,24 @@ This is a vagrant project to build and spin up a VM with the following: -
- Java IDE
- pydev
- Eclipse colour theme plugin
* Firefox
* Firefox (Iceweasel)
* Python Miniconda installation

# Getting Started

1. [Download and install VirtualBox](https://www.virtualbox.org/wiki/Downloads)
2. [Download and install Vagrant](http://www.vagrantup.com/downloads.html).
3. Go to [releases](https://github.com/martinprobson/vagrant-dev-machine/releases) and download and extract the latest source of this project.
5. In your terminal change your directory into the project directory (i.e. `cd dev-machine` )
5. In your terminal change your directory into the project directory (i.e. `cd vagrant-dev-machine` )
6. Run ```vagrant up``` to create the VM.
7. Execute ```vagrant ssh``` to login to the VM or login to XFCE via virtualbox.
8. You will need to shutdown (`shutdown -P now`) and restart (`vagrant up`) to get a graphical prompt via virtualbox - logon using vagrant/vagrant.

**NOTE** This machine will take a significant time to provision initially whilst it downloads and builds the packages required.

# User id

The user id of the VM is `ubuntu` with a password of `ubuntu`.
The user id of the VM is `vagrant` with a password of `vagrant`.

# Shared Folder

Expand Down Expand Up @@ -64,12 +65,21 @@ Then issue `vagrant up` command as usual.

# VIM

A nicer version of vim is also installed, use :PluginInstall to install the plugins from within vim itself.
A nicer version of vim is also installed, use `:PluginInstall` to install the plugins from within vim itself: -

- indentpython.vim Proper indentation for Python source.
- vim-scala scala synatax highlighting and indentation.
- nerdtree file manager (CTRL-N).
- vim-airline nice status line.
- vim-airline-themes themes for above.
- ctrl-p - ctrl-p fuzzy file matcher.
- vim-instant-markdown vim markdown syntax and previewer.

# Known Issues/To Do

1. Running `vagrant provision` multiple times can cause issues - need to fix.
2. Java heapsize in Eclipse needs to be adjusted to run Scala IDE - Eclipse shows you how to do this on first startup.
3. You may need to manually set video memory to > 16Mb in virtualbox gui in order to allow full screen operation.

# Credits

Expand Down
9 changes: 4 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ Vagrant.configure("2") do |config|

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "ubuntu/xenial64"
#config.vm.box = "ubuntu/xenial64"
config.vm.box = "debian/stretch64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
config.vm.box_check_update = false
config.vm.box_check_update = true
config.vm.define :devmachine do |t|
end

Expand Down Expand Up @@ -69,11 +70,9 @@ Vagrant.configure("2") do |config|
config.vm.hostname = "devvm"
config.vm.provision "shell", path: "scripts/10_InstallBasePackages.sh"
config.vm.provision "shell", path: "scripts/20_setPassword.sh"
config.vm.provision "shell", inline: "sudo dpkg-reconfigure xdm"
config.vm.provision "shell", inline: "systemctl restart xdm.service"
config.vm.provision "shell", path: "scripts/30_setupJava.sh"
config.vm.provision "shell", path: "scripts/40_setupEclipse.sh"
config.vm.provision "shell", path: "scripts/50_setupMiniconda.sh", privileged: false
config.vm.provision "shell", path: "scripts/50_setupMiniconda.sh", privileged: true
config.vm.provision "shell", path: "scripts/60_setup_spark.sh"

end
2 changes: 1 addition & 1 deletion resources/eclipse/eclipse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pathmunge () {
fi
fi
}
pathmunge /home/ubuntu/eclipse after
pathmunge /home/${USER}/eclipse after
4 changes: 2 additions & 2 deletions resources/miniconda/miniconda-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pathmunge () {
fi
fi
}
pathmunge /home/ubuntu/miniconda/bin
source /home/ubuntu/miniconda/bin/activate
pathmunge /home/${USER}/miniconda/bin
source /home/${USER}/miniconda/bin/activate
Binary file removed resources/vim/vim.tar.gz
Binary file not shown.
107 changes: 0 additions & 107 deletions resources/vim/vimrc

This file was deleted.

49 changes: 23 additions & 26 deletions scripts/10_InstallBasePackages.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
#!/bin/bash
source "/vagrant/scripts/common.sh"

repoUpdate () {
echo "Install base ubuntu packages"
apt-get update -y -q
}

installVBGuest () {
echo "Add contrib repo"
echo "deb http://ftp.debian.org/debian stretch-backports main contrib" >> /etc/apt/sources.list
echo "Update"
apt-get update -y -q
echo "Install virtualbox guest additions"
apt-get install -y -q virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
}


setupXfce4 () {
echo "Install XFCE4"
apt-get install -y -q xfce4 xdm xfce4-terminal
echo "Remove xterm"
apt-get remove -y -q xterm
dpkg-reconfigure xdm
cat ${XFCE4_PROFILE} >> /home/ubuntu/.bashrc
apt-get install -y -q xfce4 terminator
cat ${XFCE4_PROFILE} >> /home/${USER}/.bashrc_local
}

installOthers () {
echo "Install firefox"
apt-get -y -q install firefox
echo "Install iceweasel"
apt-get -y -q install iceweasel
echo "Install vim-gtk"
apt-get -y -q install vim-gtk
apt-get -y remove vim.tiny
apt-get install -y vim-gtk
echo "expect"
apt-get -y -q install expect
echo "git stow curl"
apt-get -y -q install git stow curl
}

setupVIM () {
echo "setup VIM GTK"
apt-get -y remove vim.tiny
apt-get install -y vim-gtk
mkdir -p $VIM_RES_DIR/vimdir
tar xf $VIM_RES_DIR/vim.tar.gz -C $VIM_RES_DIR/vimdir
cp -R $VIM_RES_DIR/vimdir /home/ubuntu/.vim
cp $VIM_RES_DIR/vimrc /home/ubuntu/.vimrc
chown -R ubuntu:ubuntu .vim .vimrc
# Set bash vim mode
echo "set -o vi" >> /home/ubuntu/.bashrc
echo "export TERM=xterm-256color" >> /home/ubuntu/.bashrc
setupDefaults () {
cd /home/${USER}
git clone https://github.com/martinprobson/dotfiles.git
sudo chown -R ${USER}:${USER} /home/${USER}/dotfiles
rm -f /home/${USER}/.bashrc
cd /home/${USER}/dotfiles
stow vim
stow bash
stow terminator
stow fonts
}

funcs=(repoUpdate installVBGuest setupXfce4 installOthers setupVIM)
funcs=(installVBGuest setupXfce4 installOthers setupDefaults)

for func in "${funcs[@]}"
do
Expand Down
12 changes: 6 additions & 6 deletions scripts/20_setPassword.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
source "/vagrant/scripts/common.sh"
function chgPassword {
echo "change password of ubuntu user"
echo "change password of ${USER} user"
apt-get -qq install expect
tee ~/chgPasswd.sh << EOF
set timeout 20
spawn sudo passwd ubuntu
expect "Enter new UNIX password:" {send "ubuntu\\r"}
expect "Retype new UNIX password:" {send "ubuntu\\r"}
spawn sudo passwd ${USER}
expect "Enter new UNIX password:" {send "${USER}\\r"}
expect "Retype new UNIX password:" {send "${USER}\\r"}
interact
EOF
expect ~/chgPasswd.sh
echo "Finished ubuntu user setup"
echo "Finished ${USER} user setup"
}


echo "setup ubuntu user"
echo "setup ${USER} user"
chgPassword
2 changes: 1 addition & 1 deletion scripts/30_setupJava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function setupEnvVars {
ln -s ${JAVA_HOME} /usr/local/java
cp $JAVA_RES_SH /etc/profile.d/java.sh
source /etc/profile.d/java.sh
echo 'source /etc/profile.d/java.sh' >> /home/ubuntu/.bashrc
echo 'source /etc/profile.d/java.sh' >> /home/${USER}/.bashrc_local
}

function setupMysqlConnector {
Expand Down
6 changes: 3 additions & 3 deletions scripts/40_setupEclipse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ installEclipse () {

changeOwner () {
echo "Changing owner of eclipse directories"
chown -R -L ubuntu:ubuntu ${ECLIPSE_TARGET}
chown -R ubuntu:ubuntu ${ECLIPSE_TARGET}
chown -R -L ${USER}:${USER} ${ECLIPSE_TARGET}
chown -R ${USER}:${USER} ${ECLIPSE_TARGET}
}

setupPath () {
echo "setup eclipse path"
cp ${ECLIPSE_RES_DIR}/eclipse.sh /etc/profile.d/.
echo 'source /etc/profile.d/eclipse.sh' >> /home/ubuntu/.bahsrc
echo 'source /etc/profile.d/eclipse.sh' >> /home/${USER}/.bashrc_local
}


Expand Down
4 changes: 2 additions & 2 deletions scripts/50_setupMiniconda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ getMinicondaInstaller () {
setupEnv () {
echo "setup miniconda environment "
sudo cp $MINICONDA_PROFILE /etc/profile.d/.
echo 'source /etc/profile.d/miniconda-profile.sh' >> /home/ubuntu/.bashrc
echo 'source /etc/profile.d/miniconda-profile.sh' >> /home/${USER}/.bashrc_local
}

installMiniconda() {
Expand All @@ -19,7 +19,7 @@ installMiniconda() {
fi
echo "Installing miniconda"
bash $MINICONDA_INSTALLER -b -p ${MINICONDA_INSTALL_LOCATION}
sudo chown -R ubuntu:ubuntu ${MINICONDA_INSTALL_LOCATION}
sudo chown -R ${USER}:${USER} ${MINICONDA_INSTALL_LOCATION}
}


Expand Down
7 changes: 5 additions & 2 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ fileExists () {
fi
}

# User
USER=vagrant

# xfce4
XFCE4_PROFILE=/vagrant/resources/xfce4/xfce4.sh

Expand All @@ -42,7 +45,7 @@ JAVA_RES_SH=/vagrant/resources/java/java.sh

# eclipse IDE
ECLIPSE_RES_DIR=/vagrant/resources/eclipse
ECLIPSE_TARGET=/home/ubuntu/eclipse
ECLIPSE_TARGET=/home/${USER}/eclipse
ECLIPSE_DESKTOP_ENTRY=${ECLIPSE_RES_DIR}/eclipse.desktop


Expand All @@ -52,7 +55,7 @@ MINICONDA_VERSION=latest
MINICONDA_ARCH=Linux-x86_64
MINICONDA_DOWNLOAD_URL=https://repo.continuum.io/miniconda
MINICONDA_ARCHIVE=${MINICONDA_MAJOR_VERSION}-${MINICONDA_VERSION}-${MINICONDA_ARCH}.sh
MINICONDA_INSTALL_LOCATION=/home/ubuntu/miniconda
MINICONDA_INSTALL_LOCATION=/home/${USER}/miniconda
MINICONDA_INSTALLER=/vagrant/resources/miniconda/miniconda.sh
MINICONDA_PROFILE=/vagrant/resources/miniconda/miniconda-profile.sh

Expand Down

0 comments on commit 7706678

Please sign in to comment.