Commit 5345e78fd9a169b57b9b60615f85fb7f822fec3c

Authored by Josafá Filho
2 parents 146f9fe3 524d169e
Exists in master and in 1 other branch issue488

Fix pensandoodireito/participacao-sitebase#342

@@ -7,20 +7,20 @@ require 'ffi' @@ -7,20 +7,20 @@ require 'ffi'
7 VAGRANTFILE_API_VERSION = "2" 7 VAGRANTFILE_API_VERSION = "2"
8 8
9 $firstTimeScript = <<SCRIPT 9 $firstTimeScript = <<SCRIPT
10 -cd /vagrant && composer update && rm -r /var/www/public && ln -s /vagrant/src /var/www/public  
11 -  
12 -cp /vagrant/config/wp-config-vagrant.php /vagrant/src/wp-config.php  
13 -cp /vagrant/config/htaccess-vagrant /vagrant/src/.htaccess 10 +apt-get update
  11 +apt-get install -y subversion
  12 +composer self-update
14 13
  14 +cd /vagrant
  15 +composer update
15 npm install 16 npm install
16 ./node_modules/.bin/gulp 17 ./node_modules/.bin/gulp
17 -  
18 service apache2 start 18 service apache2 start
19 -  
20 service mysql start 19 service mysql start
21 20
22 mysql --user=root --password=root -h 127.0.0.1 -e 'DROP DATABASE IF EXISTS participacao' 21 mysql --user=root --password=root -h 127.0.0.1 -e 'DROP DATABASE IF EXISTS participacao'
23 mysql --user=root --password=root -h 127.0.0.1 -e 'CREATE DATABASE participacao' 22 mysql --user=root --password=root -h 127.0.0.1 -e 'CREATE DATABASE participacao'
  23 +
24 cd /vagrant/db 24 cd /vagrant/db
25 bunzip2 db.sql.bz2 25 bunzip2 db.sql.bz2
26 mysql --user=root --password=root -h 127.0.0.1 participacao < /vagrant/db/db.sql 26 mysql --user=root --password=root -h 127.0.0.1 participacao < /vagrant/db/db.sql
@@ -30,13 +30,13 @@ SCRIPT @@ -30,13 +30,13 @@ SCRIPT
30 30
31 $updateServices = <<SCRIPT 31 $updateServices = <<SCRIPT
32 32
33 -service mysql start 33 +service mysql restart
34 34
35 rm -r /var/www/public 35 rm -r /var/www/public
36 ln -s /vagrant/src/ /var/www/public 36 ln -s /vagrant/src/ /var/www/public
37 chmod 777 /vagrant/src/wp-content/ 37 chmod 777 /vagrant/src/wp-content/
38 38
39 -service apache2 start 39 +service apache2 restart
40 40
41 SCRIPT 41 SCRIPT
42 42
@@ -46,6 +46,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| @@ -46,6 +46,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
46 config.vm.box = "scotch/box" 46 config.vm.box = "scotch/box"
47 config.vm.network "forwarded_port", guest: 80, host: 80 47 config.vm.network "forwarded_port", guest: 80, host: 80
48 config.vm.network "forwarded_port", guest: 80, host: 8080 48 config.vm.network "forwarded_port", guest: 80, host: 8080
  49 + config.vm.network "forwarded_port", guest: 3306, host: 3306
49 # Port de debug do xdebug 50 # Port de debug do xdebug
50 config.vm.network "forwarded_port", guest: 9000, host: 9000 51 config.vm.network "forwarded_port", guest: 9000, host: 9000
51 config.vm.network "private_network", ip: "192.168.33.10" 52 config.vm.network "private_network", ip: "192.168.33.10"
@@ -61,6 +62,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| @@ -61,6 +62,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
61 system("sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080") 62 system("sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080")
62 elsif FFI::Platform::IS_MAC 63 elsif FFI::Platform::IS_MAC
63 system('echo " 64 system('echo "
  65 + rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 3306 -> 127.0.0.1 port 3306
64 rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080 66 rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080
65 rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 8443 67 rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 8443
66 " | sudo pfctl -ef - > /dev/null 2>&1;') 68 " | sudo pfctl -ef - > /dev/null 2>&1;')
@@ -5,21 +5,6 @@ @@ -5,21 +5,6 @@
5 "url": "http://wpackagist.org" 5 "url": "http://wpackagist.org"
6 }, 6 },
7 { 7 {
8 - "type": "package",  
9 - "package": {  
10 - "name": "wordpress",  
11 - "type": "webroot",  
12 - "version": "4.1.1",  
13 - "dist": {  
14 - "type": "zip",  
15 - "url": "http://br.wordpress.org/wordpress-4.1.1-pt_BR.zip"  
16 - },  
17 - "require" : {  
18 - "fancyguy/webroot-installer": "1.0.0"  
19 - }  
20 - }  
21 - },  
22 - {  
23 "type": "git", 8 "type": "git",
24 "url": "https://github.com/pensandoodireito/marcocivil-tema" 9 "url": "https://github.com/pensandoodireito/marcocivil-tema"
25 }, 10 },
@@ -58,7 +43,7 @@ @@ -58,7 +43,7 @@
58 ], 43 ],
59 "require": { 44 "require": {
60 "php": ">=5.4.0", 45 "php": ">=5.4.0",
61 - "wordpress": "4.1.1", 46 + "johnpbloch/wordpress": "4.1",
62 "pensandoodireito/marcocivil-tema" : "dev-master", 47 "pensandoodireito/marcocivil-tema" : "dev-master",
63 "pensandoodireito/dadospessoais-tema" : "dev-master", 48 "pensandoodireito/dadospessoais-tema" : "dev-master",
64 "pensandoodireito/pensandoodireito-tema" : "dev-master", 49 "pensandoodireito/pensandoodireito-tema" : "dev-master",
@@ -67,10 +52,9 @@ @@ -67,10 +52,9 @@
67 "pensandoodireito/pensandoodireito-network-functions" : "dev-master", 52 "pensandoodireito/pensandoodireito-network-functions" : "dev-master",
68 "pensandoodireito/blog-tema" : "dev-master", 53 "pensandoodireito/blog-tema" : "dev-master",
69 "pensandoodireito/wp-side-comments" : "dev-master", 54 "pensandoodireito/wp-side-comments" : "dev-master",
70 - "ethymos/delibera" : "dev-master", 55 + "ethymos/delibera" : "dev-master",
71 "wpackagist-plugin/rich-text-tags": "1.7.3", 56 "wpackagist-plugin/rich-text-tags": "1.7.3",
72 "wpackagist-plugin/json-rest-api": "1.1.1", 57 "wpackagist-plugin/json-rest-api": "1.1.1",
73 - "wpackagist-plugin/contact-form-plugin": "3.89",  
74 "wpackagist-plugin/sendpress": ">=1.1.7.21", 58 "wpackagist-plugin/sendpress": ">=1.1.7.21",
75 "wpackagist-plugin/social-share-button": "2.1", 59 "wpackagist-plugin/social-share-button": "2.1",
76 "wpackagist-plugin/events-manager": "5.5.7.1", 60 "wpackagist-plugin/events-manager": "5.5.7.1",
@@ -79,12 +63,17 @@ @@ -79,12 +63,17 @@
79 "composer/installers": "~1.0" 63 "composer/installers": "~1.0"
80 }, 64 },
81 "extra": { 65 "extra": {
82 - "webroot-dir": "src",  
83 - "webroot-package": "wordpress", 66 + "wordpress-install-dir": "src/wp",
84 "installer-paths": { 67 "installer-paths": {
85 "src/wp-content/plugins/{$name}/": ["type:wordpress-plugin"], 68 "src/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
86 "src/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"], 69 "src/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
87 "src/wp-content/themes/{$name}/": ["type:wordpress-theme"] 70 "src/wp-content/themes/{$name}/": ["type:wordpress-theme"]
88 } 71 }
  72 + },
  73 + "scripts": {
  74 + "pre-install-cmd": "/bin/bash ./pre-update.sh",
  75 + "pre-update-cmd": "/bin/bash ./pre-update.sh",
  76 + "post-update-cmd": "/bin/bash ./post-update.sh",
  77 + "post-install-cmd": "/bin/bash ./post-update.sh"
89 } 78 }
90 } 79 }
config/file-remote.php 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +<?php
  2 +$path = $_GET{'src'};
  3 +
  4 +$dirs = explode('/', $path);
  5 +$img = implode('/', $dirs);
  6 +
  7 +if(strpos($img, ".jpg") !== false || strpos($img, ".jpeg")){
  8 + $contentType = "image/jpeg";
  9 +}elseif(strpos($img, ".png") !== false){
  10 + $contentType = "image/png";
  11 +}else{
  12 + $contentType = "image/gif";
  13 +}
  14 +
  15 +header("Content-Type: {$contentType}", true);
  16 +ob_start();
  17 +if(file_exists($img)){
  18 + readfile($img);
  19 + die;
  20 +}else{
  21 + array_pop($dirs);
  22 + $localDir = implode('/', $dirs);
  23 + if(!file_exists($localDir) || !is_dir($localDir)){
  24 + mkdir($localDir, 777, true);
  25 + }
  26 + $content = file_get_contents("http://pensando.mj.gov.br/{$img}");
  27 + file_put_contents($img, $content);
  28 + ob_clean();
  29 + echo $content;
  30 +}
config/htaccess-vagrant
@@ -6,12 +6,12 @@ RewriteRule ^index\.php$ - [L] @@ -6,12 +6,12 @@ RewriteRule ^index\.php$ - [L]
6 # add a trailing slash to /wp-admin 6 # add a trailing slash to /wp-admin
7 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] 7 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
8 8
9 -RewriteRule (^wp\-content\/[^.]+\.(jpe?g|gif|bmp|png))$ /file.php?src=$1 [L] 9 +RewriteRule (^wp\-content\/[^.]+\.(jpe?g|gif|bmp|png))$ /file-remote.php?src=$1 [L]
10 10
11 RewriteCond %{REQUEST_FILENAME} -f [OR] 11 RewriteCond %{REQUEST_FILENAME} -f [OR]
12 RewriteCond %{REQUEST_FILENAME} -d 12 RewriteCond %{REQUEST_FILENAME} -d
13 RewriteRule ^ - [L] 13 RewriteRule ^ - [L]
14 RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] 14 RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
15 -RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] 15 +RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
16 RewriteRule . index.php [L] 16 RewriteRule . index.php [L]
17 </IfModule> 17 </IfModule>
config/index-vagrant.php 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +<?php
  2 +/**
  3 + * Front to the WordPress application. This file doesn't do anything, but loads
  4 + * wp-blog-header.php which does and tells WordPress to load the theme.
  5 + *
  6 + * @package WordPress
  7 + */
  8 +
  9 +/**
  10 + * Tells WordPress to load the WordPress theme and output it.
  11 + *
  12 + * @var bool
  13 + */
  14 +define('WP_USE_THEMES', true);
  15 +
  16 +/** Loads the WordPress Environment and Template */
  17 +require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
config/wp-config-vagrant.php
@@ -97,11 +97,14 @@ define(&#39;PATH_CURRENT_SITE&#39;, &#39;/&#39;); @@ -97,11 +97,14 @@ define(&#39;PATH_CURRENT_SITE&#39;, &#39;/&#39;);
97 define('SITE_ID_CURRENT_SITE', 1); 97 define('SITE_ID_CURRENT_SITE', 1);
98 define('BLOG_ID_CURRENT_SITE', 1); 98 define('BLOG_ID_CURRENT_SITE', 1);
99 99
  100 +define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/wp-content/plugins' );
  101 +define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content' );
  102 +
100 /* Isto é tudo, pode parar de editar! :) */ 103 /* Isto é tudo, pode parar de editar! :) */
101 104
102 /** Caminho absoluto para o diretório WordPress. */ 105 /** Caminho absoluto para o diretório WordPress. */
103 if ( !defined('ABSPATH') ) 106 if ( !defined('ABSPATH') )
104 - define('ABSPATH', dirname(__FILE__) . '/'); 107 + define('ABSPATH', dirname(__FILE__) . '/wp/');
105 108
106 /** Configura as variáveis do WordPress e arquivos inclusos. */ 109 /** Configura as variáveis do WordPress e arquivos inclusos. */
107 require_once(ABSPATH . 'wp-settings.php'); 110 require_once(ABSPATH . 'wp-settings.php');
post-update.sh 0 → 100755
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +cp config/wp-config-vagrant.php src/wp-config.php
  2 +cp config/htaccess-vagrant src/.htaccess
  3 +cp config/file-remote.php src/file-remote.php
  4 +cp config/index-vagrant.php src/index.php
  5 +rm -f src/wp/index.php
  6 +ln -s wp/wp-admin src/wp-admin
  7 +ln -s wp/wp-includes src/wp-includes
0 \ No newline at end of file 8 \ No newline at end of file
pre-update.sh 0 → 100755
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +#!/usr/bin/env bash
  2 +rm -rf src/wp-admin src/wp-includes src/*.php src/.htaccess
0 \ No newline at end of file 3 \ No newline at end of file
src/file-remote.php
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -<?php  
2 -$path = $_GET{'src'};  
3 -  
4 -$dirs = explode('/', $path);  
5 -$img = implode('/', $dirs);  
6 -  
7 -if(strpos($img, ".jpg") !== false || strpos($img, ".jpeg")){  
8 - $contentType = "image/jpeg";  
9 -}elseif(strpos($img, ".png") !== false){  
10 - $contentType = "image/png";  
11 -}else{  
12 - $contentType = "image/gif";  
13 -}  
14 -  
15 -header("Content-Type: {$contentType}", true);  
16 -  
17 -if(file_exists($img)){  
18 - $content = file_get_contents($img);  
19 -}else{  
20 - array_pop($dirs);  
21 - $localDir = implode('/', $dirs);  
22 - if(!file_exists($localDir) || is_dir($localDir)){  
23 - mkdir($localDir, 777, true);  
24 - }  
25 - $content = file_get_contents("http://pensando.mj.gov.br/{$img}");  
26 - file_put_contents($img, $content);  
27 -}  
28 -  
29 -die($content);