#!/bin/bash

# -----------------------------------------------------------------------------
#
# Basic configuration to our VM
#
# -----------------------------------------------------------------------------

APP_DOMAIN="webservice.ufmg-dev.br"

# Load the functions needed to our shell provider
source ${provision_path}/functions.sh

# Define the machine hostname
host=$(hostname)

if [ "${host}" != "${APP_DOMAIN}" ]; then
  hostnamectl set-hostname ${APP_DOMAIN}
fi

# Define the /etc/hosts
grep -q "${APP_DOMAIN}" /etc/hosts

if [ $? -ne 0 ]; then
  bash -c "echo \"192.168.13.13 ${APP_DOMAIN}\" >> /etc/hosts"
fi

# Install the bash profiles
copy_file ${provision_path}/files/bashrc /home/vagrant/.bashrc
copy_file ${provision_path}/files/bash_profile /home/vagrant/.bash_profile

# Setting up the environment
bash -c "cat ${provision_path}/files/environment >> /etc/environment"

# Setting up the common bashrc
copy_file ${provision_path}/files/motd /etc/motd

# Update the system
apt-get upgrade -qq -y

# Install basics packages
install_packages git nscd screen python-virtualenv python-dev unzip

# Make sure that nscd is running
service nscd start
