Skip to content

Instantly share code, notes, and snippets.

@vitalbh
Last active December 22, 2015 10:59
Show Gist options
  • Save vitalbh/6462770 to your computer and use it in GitHub Desktop.
Save vitalbh/6462770 to your computer and use it in GitHub Desktop.
bootstrap vagrant
#!/usr/bin/env bash
sudo apt-get install wget curl memcached
apt-get install redis-server
cp /etc/redis/redis.conf /etc/redis/redis.conf.default
# composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
#start services
service memcached restart;
service redis-server restart;
set -x
cd /tmp
if ! test -d /usr/local/include/luajit-2.0; then
echo "Installing LuaJIT-2.0.1."
wget "http://luajit.org/download/LuaJIT-2.0.1.tar.gz"
tar -xzvf LuaJIT-2.0.1.tar.gz
cd LuaJIT-2.0.1
make
sudo make install
else
echo "Skipping LuaJIT-2.0.1, as it's already installed."
fi
cd /tmp
mkdir ngx_devel_kit
cd ngx_devel_kit
wget "https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz"
tar -xzvf v0.2.18.tar.gz
NGX_DEV="/tmp/ngx_devel_kit/ngx_devel_kit-0.2.18"
cd /tmp
mkdir lua-nginx-module
cd lua-nginx-module
wget "https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.7.tar.gz"
tar -xzvf v0.8.7.tar.gz
LUA_MOD="/tmp/lua-nginx-module/lua-nginx-module-0.8.7"
cd /tmp
wget 'http://nginx.org/download/nginx-1.4.2.tar.gz'
tar -xzvf nginx-1.4.2.tar.gz
cd ./nginx-1.4.2
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0
./configure --prefix=/opt/nginx \
--add-module=$NGX_DEV \
--add-module=$LUA_MOD
make -j2
sudo make install
unset LUAJIT_LIB
unset LUAJIT_INC
#!/usr/bin/env bash
apt-get install php5-fpm php-pear php5-cli php5-dev php-apc php5-curl php5-mysql php5-memcached php5-intl
#!/bin/bash
# Get su permission
sudo su
# Clone the repo
git clone https://github.com/phalcon/cphalcon.git
cd cphalcon
# Get our HEADs to test is an update is necessary
touch /tmp/phalcon-head
INSTALLED_HEAD=$(cat /tmp/phalcon-head)
REPO_HEAD=$(cat .git/refs/heads/master)
if [ "$INSTALLED_HEAD" == "$REPO_HEAD" ]; then
# Nothing to do here
echo
echo 'PHP extension for Phalcon is up to date'
echo
else
# Install/Update Phalcon
echo
echo 'Building Phalcon'
echo
# Run build script
cd build
./install
wait
if [ ! -f '/etc/php5/mods-available/phalcon.ini' ]; then
# Ensure extension is loaded for php-cli and php-fpm
echo 'extension=phalcon.so' > /etc/php5/mods-available/phalcon.ini
ln -s /etc/php5/mods-available/phalcon.ini /etc/php5/cli/conf.d/phalcon.ini
ln -s /etc/php5/mods-available/phalcon.ini /etc/php5/fpm/conf.d/phalcon.ini
fi
# Restart php5-fpm and nginx
echo
echo 'Restarting web services'
echo
service php5-fpm restart
service nginx restart
# Update the file that contains the installed HEAD
cd ../
cat .git/refs/heads/master > /tmp/phalcon-head
echo
echo 'PHP extension for Phalcon has been updated'
echo
fi
if [ ! -f "/usr/local/bin/phalcon.php" ]; then
echo
echo 'Installing/Upating Phalcon dev-tools'
echo
git clone https://github.com/phalcon/phalcon-devtools.git /usr/local/bin
cd /usr/local/bin
. ./phalcon.sh
rm phalcon
ln -s /usr/local/bin/phalcon.php /usr/local/bin/phalcon
fi
# Clean up
exit
cd /home/`whoami`
sudo rm -rf cphalcon
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
class { 'apt': always_apt_update => true }
class system::update {
$packages = [ "build-essential" ]
package { $packages:
ensure => present,
require => Class['apt::update'],
}
}
class git::install {
$packages = [ "git" ]
package { $packages:
ensure => latest,
require => Class['apt::update'],
}
}
class basic::packages{
package{"tmux": ensure => installed}
package{"curl": ensure => installed}
package{"vim": ensure => installed}
package{"htop": ensure => installed}
}
class php::install {
apt::ppa { "ppa:ondrej/php5": }
apt::key { "ondrej": key => "E5267A6C" }
$packages = [ "php5-fpm","php-pear", "php5-cli", "php5-dev", "php5-gd", "php5-curl", "php-apc", "php5-mcrypt", "php5-sqlite", "php5-mysql", "php5-memcached", "php5-intl", "php5-tidy", "php5-imap", "php5-xdebug"]
package { $packages:
ensure => latest,
require => Class['apt::update'],
}
}
class { 'memcached':
max_memory => 2048
}
exec { 'apt-get update':
command => "/usr/bin/apt-get update -y",
onlyif => "/bin/bash -c 'exit $(( $(( $(date +%s) - $(stat -c %Y /var/lib/apt/lists/$( ls /var/lib/apt/lists/ -tr1|tail -1 )) )) <= 604800 ))'"
}
include system::update
include git::install
include php::install
include mongodb
#include nginx
include nginx::fcgi
nginx::fcgi::site {"default":
root => "/vagrant/src/Public",
fastcgi_pass => "unix:/var/run/php5-fpm.sock",
server_name => ["localhost", "$hostname", "$fqdn"],
}
class { 'mysql::server':
config_hash => { 'root_password' => 'redeinterna' }
}
mysql::db { 'dbname':
user => 'eth1',
password => 'redeinterna',
host => '192.168.0.56',
grant => ['all'],
}
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 80, host: 8081
config.vm.provision :shell, :path => "provision/shell/bootstrap.sh"
# TODO: fix this hack that ensures 'apt-get update' runs before mysql
# is provisioned with puppet
config.vm.provision :shell, :inline => "apt-get update --fix-missing"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "provision/puppet/manifests"
puppet.module_path = "provision/puppet/modules"
puppet.manifest_file = "base.pp"
puppet.options = ['--verbose']
end
# installer/updater for cphalcon
# installer for phalcon-devtools
config.vm.provision :shell do |sh|
sh.path = "provision/shell/install_phalcon.sh"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment