#!/bin/bash # # Custom init script for contextualized VMs # # François 2014,Apr. # # # Start network # # Note: vm-context service is supposed to contains network # setup ... except in CloudMIP because the DHCP server gives # all of the needed parameters. service network restart # Install software yum --skip-broken --nogpgcheck -y install httpd php # Retrieve web application from context # Note the WWW_SRC variable that belong to the CONTEXT image file src="/mnt/${WWW_SRC}" dst="/var/www/html" cd ${dst} if [ -d ${src} ]; then # DIR type cp -af ${src}/* . else # FILE type (archive/gzip or bz2 or ...) _type=$(file -b ${src}) if [ $(echo -e ${_type} | grep -iqE "^gzip"; echo $?) -eq 0 ]; then _compress_flag="-z" elif [ $(echo -e ${_type} | grep -iqE "^bzip2"; echo $?) -eq 0 ]; then _compress_flag="-j" elif [ $(echo -e ${_type} | grep -iqE "^xz"; echo $?) -eq 0 ]; then _compress_flag="-J" fi # untar with/without uncompress tar ${_compress_flag} -xvf ${src} fi chown -R apache:apache ${dst} # Start application service httpd start