1 - Do que você precisará inicialmente:
http://www.brazilfw.com.br/users/luapuf ... hunder.tgz # pacote do thunder
http://www.sqlite.org/sqlite-3.7.0.1.so.gz # lib do sqlite
2 - Cópia de arquivos:
Você precisará copiar os arquivos necessários para dentro do BFW, além de setar as devidas permissões. Para isso, se oriente pelo arquivo "instalar" que o Luapufo colocou dentro do arquivo compactado.
No meu caso, como sou viciado em manipular os arquivos do BFW via WinSCP, acabei preferindo criar toda a estrutura de pastas na mão e depois copiei os arquivos lá pra dentro.
3 - Criação e adaptação dos scripts:
Você precisará trabalhar em cima do arquivo thunder.conf (este já vem no pacote, você só precisa configurá-lo);
Criar o arquivo /etc/init.d/thunder (pois este não vem junto com o pacote);
Alterar o squid.conf, para incluir os redirecionamentos para o Thunder.
4 - Empacotamento:
Graças ao tutorial, esta etapa é tranquila - viewtopic.php?f=91&t=69094&start=40#p188988
O meu ficou assim
- Código: Selecionar todos
/lib/libsqlite3.so.0
/usr/local/sbin/thunder
/etc/init.d/thunder
/etc/thunder/*
/etc/thunder/plugins/*
/var/log/thunder/*
/var/tmp/thunder/*
/var/run/thunder/*
/var/addon-list/thundercache.pkg
Bem amigo, basicamente, foi isso que fiz. Mas ainda faltam algumas coisas, como a parte do PHP, relatórios, e mais alguns scripts de manutenção no cron e desligamento seguro.
Tente começar com estas dicas, além daquelas que já foram postadas anteriormente, e no que eu puder ajudar é só falar.... abraço.
# PARAMETROS PARA O THUNDER
CACHEDIR /partition/thunder/
PLUGINSDIR /etc/thunder/plugins/
ACCESSLOG /var/log/thunder/access.log
ERRORLOG /var/log/thunder/thunder.log
PIDFILE /var/run/thunder/thunder.pid
#--------------------------------------------------|
# SETTINGS PARA O THUNDER
USER root
GROUP root
PORT 8080
SERVERNUMBER 8
MAXSERVERS 100
#--------------------------------------------------|
reginaldo escreveu:Tópico Anterior: viewtopic.php?f=77&t=76747&start=0#p240059
O tópico original do franciscojsh ficou poluido.
Eu sou um dos culpados. franciscojsh desculpa.
Ele foi trancado e aberto este Tópico de mesmo título.
Aqui deverá ser discutido somente o proposto pelo franciscojsh. Ou seja o Desenvolvimento gratuito do "ThunderCache 3.1" para o BFW 3.x
Qualquer coisa diferente disso será apagado sem prévio aviso.
Lano escreveu:Olá franciscojsh e rapaziada do forum! Tenho acompanhado o tópico "de longe" pois tenho enfrentado problemas de saúde na familia, e fico preocupado em começar e depois acabar falhando com vocês.
Com as dicas do Luapufo consegui colocar meu thundercache 3.0 para funcionar (sem a parte dos relatórios), porém cacheando perfeitamente. Acontece que com a versão 3.1 o máximo que consegui até agora foi ver os arquivos sendo cacheados na pasta correta, porém eles não estão sendo entregues durante as solicitações.
Ainda não consegui sair desta parte porque não tive tempo pra fazer mais testes devido aos problemas que comentei no início.
Quero trabalhar junto com vocês, mas antes sugiro a gente "sincronizar nossos relogios".
Em que parte cada um dos integrantes deste "multirão" está? Todos já conseguiram êxito com a versão 3.0? Dos que não conseguiram, o que falta para terminar?
O meu objetivo aqui é juntamente com vocês, por a versão 3.1 pra funcionar. Mas se quiserem começar pela 3.0 poderei postar os scripts ok.
Abraço à todos, para o alto e avante!
get-pkg /users/luapufo/thunder/install
http://www.brazilfw.com.br/users/luapufo/thunder
[brazilfw]~# get-pkg /users/luapufo/thunder/install
Instalacao 1.0
Stopping mysql... done
Starting mysql... done
Stopping squid... done
Attention, configuration thunder found.
Want to delete?
Continue (y/n)
y
Connecting to www.brazilfw.com.br (206.217.198.112:80)
thunder-conf.bfw 100% |*******************************| 5025 --:--:-- ETA
0
Attention, database stiph found.
Want to delete?
Continue (y/n)
y
ERROR 1396 (HY000) at line 2: Operation CREATE USER failed for 'thunder'@'127.0.0.1'
Connecting to www.brazilfw.com.br (206.217.198.112:80)
wget: server returned error: HTTP/1.1 404 Not Found
Stopping mysql... done
Starting mysql... done
Starting squid... done
Writing configuration files...
Done.
[ -e "/mnt/thunder.bfw" ] && rm -fr /mnt/thunder.bfw
wget http://www.brazilfw.com.br/users/luapufo/thunder.bfw -P /mnt
extract "/mnt/thunder.bfw"
[brazilfw]/# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.86 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> DROP USER thunder@127.0.0.1;
Query OK, 0 rows affected (0.00 sec)
mysql> Aborted
[brazilfw]/# get-pkg /users/luapufo/thunder/install
Instalacao 1.0
Stopping mysql... done
Starting mysql... done
Stopping squid... done
Attention, configuration thunder found.
Want to delete?
Continue (y/n)
y
Connecting to www.brazilfw.com.br (206.217.198.112:80)
thunder-conf.bfw 100% |*******************************| 5025 --:--:-- ETA
0
Connecting to www.brazilfw.com.br (206.217.198.112:80)
thunder.bfw 100% |*******************************| 91447 00:00:00 ETA
0
Stopping mysql... done
Starting mysql... done
Starting squid... done
Writing configuration files...
Done.
[brazilfw]/#
/etc/init.d/thunder: line 194: thunder-monitor: not found
GEFSANTANA escreveu:Ao startar o thunder através do console exibe-se a seguinte mensagem:
- Código: Selecionar todos
/etc/init.d/thunder: line 194: thunder-monitor: not found
/usr/sbin/thunder-monitor
brunovescovi escreveu:O thunder-monitor é executado em conjunto com o thunder e fica no local abaixo:
- Código: Selecionar todos
/usr/sbin/thunder-monitor
Se não estiver lá, houve algum problema na instalação do thunder.
Tente instalar novamente.
franciscojsh escreveu:brunovescovi escreveu:O thunder-monitor é executado em conjunto com o thunder e fica no local abaixo:
- Código: Selecionar todos
/usr/sbin/thunder-monitor
Se não estiver lá, houve algum problema na instalação do thunder.
Tente instalar novamente.
Bruno, acabo de reinstalar e de fato esse arquivo não é criado lá no usr/sbin/
brunovescovi escreveu:Fui verificar aqui e realmente o luapufo não colocou no pacote.
Tem dois jeitos de resolver:
01 - O luapufo incluir no thunder.bfw, porque esse arquivo é dele.
02 - Edite o arquivo /etc/init.d/thunder e retire a linha que chama o thunder-monitor. O thunder-monitor é chamado em conjunto com o thunder e, pelo nome, deve ficar verificando se o thunder caiu, assim como o route-monitor, que fica verificando as conexões para refazer as regras do smartroute.
Se o luapufo não disponibilizar o arquivo, tem que tirar ele do script de inicialização como expliquei.
GEFSANTANA escreveu:Ao startar o thunder através do console exibe-se a seguinte mensagem:
- Código: Selecionar todos
/etc/init.d/thunder: line 194: thunder-monitor: not found
Não, GEFSANTANA.GEFSANTANA escreveu:Pelo que andei analisando este thunder-monitor tem razão de existir, pelo que andei analisando ele parece ser responsável por registrar o log do thunder no banco de dados do mysql. Pois, acessei o banco e ele permanece vazio.
franciscojsh escreveu:GEFSANTANA escreveu:Ao startar o thunder através do console exibe-se a seguinte mensagem:
- Código: Selecionar todos
/etc/init.d/thunder: line 194: thunder-monitor: not found
Andei pesquisando no google sobre, mas ainda não achei algo válido para resolver isso .
*)
echo;echo "Usage: {start|stop|restart|force-reload|reload|reload-lists|bd}";echo;;
esac
Lano escreveu:Galera funcionou! Como mudei a estrutura, acabei esquecendo de refazer o caminho do thunder.lst.
Ainda precisa de uns ajustes, mas caso vocês quiserem, posso disponibilizar o que já tenho aqui. Daí a gente trabalha em cima dele para ir melhorando até podermos postar pra geral.
Abraço... aguardo contato.
#!/bin/sh
#
# By LUAPUFO 16-08-2010
#---------------------------------------------------------------------|
. /etc/thunder
. /lib/system-functions
. /etc/brazilfw/brazilfw.cfg
Thunder_BIN=/usr/local/sbin/thunder
Thunder_CONFIG=/etc/brazilfw/custom/thunder.conf
PIDFILE=/var/run/thunder.pid
acl() {
echo "acl thunder_lst url_regex -i \"/etc/thunder/thunder.lst\" " >> /etc/brazilfw/custom/squid.acl
echo "cache deny thunder_lst" >> /etc/brazilfw/custom/squid.acl
echo "cache_peer 127.0.0.1 parent 8080 0 proxy-only no-digest" >> /etc/brazilfw/custom/squid.acl
echo "dead_peer_timeout 2 seconds" >> /etc/brazilfw/custom/squid.acl
echo "cache_peer_access 127.0.0.1 allow thunder_lst" >> /etc/brazilfw/custom/squid.acl
echo "cache_peer_access 127.0.0.1 deny all" >> /etc/brazilfw/custom/squid.acl
}
acl_remove() {
eval "sed -i '/acl thunder_lst url_regex -i/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
eval "sed -i '/cache deny thunder_lst/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
eval "sed -i '/cache_peer 127.0.0.1 parent 8080 0 proxy-only no-digest/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
eval "sed -i '/dead_peer_timeout 2 seconds/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
eval "sed -i '/cache_peer_access 127.0.0.1 allow thunder_lst/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
eval "sed -i '/cache_peer_access 127.0.0.1 deny all/d' /etc/brazilfw/custom/squid.acl" >/dev/null 2>&1
}
bd_thunder() {
if [ ! -e "/partition/mysql/thunder" ]; then
mysql -u root -p < /etc/thunder/thunder.sql
fi
}
pasta() {
if [ ! -d "/partition/thunder" ]; then
echo -n "Creating a folder for thunder cache... "
mkdir -p /partition/thunder >/dev/null 2>&1
fi
if [ ! -d "/partition/thunder/log" ]; then
echo -n "Creating a folder for system logging... "
mkdir -p /partition/thunder/log >/dev/null 2>&1
fi
if [ ! -d "/partition/thunder/cache" ]; then
echo -n "Creating a folder for the cache of Thunder... "
mkdir -p /partition/thunder/cache >/dev/null 2>&1
fi
if [ ! -f /var/htdocs/webadmin/thunder/index.php ]; then
echo ""
else
ln -s /etc/thunder/thunder.php /var/htdocs/webadmin/thunder/index.php >/dev/null 2>&1
fi
}
verifica() {
if [ "$ENABLE_THUNDER" != "yes" ]; then
[ -e "/var/run/thunder.pid" ] && stop
echo "Warning: THUNDER disabled in configuration"
exit
fi
if [ "$CACHE_DISK" != "yes" ]; then
[ -e "/var/run/thunder.pid" ] && stop
echo "Warning: SQUID disable in configuration"
exit
else
if [ ! -f "/var/run/squid.pid" ]; then
echo "Squid esta parado"
exit
else
echo ""
fi
fi
}
reload_thunder()
{
echo "Reloading Thunder ..."
if test ! -d $(dirname $PIDFILE); then
mkdir $(dirname $PIDFILE)
fi
PID="`cat $PIDFILE`"
if [ "$PID" != "" ]; then
kill -HUP "$PID" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: Thunder not running"
exit 1
fi
else
echo "Error: Thunder not running or PIDFILE not readable"
exit 1
fi
exit 0
}
case "$1" in
start)
echo "Starting Thunder ..."
if [ ! -f $Thunder_BIN ]; then
echo "Error: $Thunder_BIN not found"
exit 5
fi
verifica
pasta
bd_thunder
cat /etc/brazilfw/custom/squid.acl | grep "cache deny thunder_lst" >/dev/null 2>&1
[ "$?" != "0" ] && acl
/etc/init.d/squid reload >/dev/null 2>&1
# thunder-monitor &
$Thunder_BIN -c $Thunder_CONFIG
;;
stop)
echo "Shutting down Thunder ..."
if [ ! -f "$PIDFILE" ]; then
echo "Error: Thunder not running or PIDFILE unreadable"
exit 1
fi
# killall thunder-monitor >/dev/null 2>&1
killall sleep >/dev/null 2>&1
cat /etc/brazilfw/custom/squid.acl | grep "cache deny thunder_lst" >/dev/null 2>&1
[ "$?" != "1" ] && acl_remove
/etc/init.d/squid reload >/dev/null 2>&1
PID="`cat $PIDFILE`"
if [ "$PID" != "" ]; then
kill -TERM "$PID" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: Thunder not running"
exit 1
fi
else
echo "Error: Thunder not running or PIDFILE unreadable"
exit 1
fi
sleep 2
exit 0
;;
restart)
echo "Shutting down Thunder ..."
$0 stop >/dev/null 2>&1
$0 start
exit $?
;;
reload-lists)
reload_thunder
;;
force-reload)
reload_thunder
;;
reload)
reload_thunder
;;
bd)
bd_thunder
;;
status)
echo "Checking for service Thunder ..."
exit 4
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|reload|reload-lists|bd}"
exit 0
;;
esac
# Parametros para o Thunder
CACHEDIR /partition/thunder/cache/
ACCESSLOG /partition/thunder/log/access.log
ERRORLOG /partition/thunder/log/thunder.log
PLUGINSDIR /etc/thunder/plugins/
PIDFILE /var/run/thunder.pid
#--------------------------------------------------|
# Configurações do MySQL
MYSQL_HOST 127.0.0.1
MYSQL_USER thunder
MYSQL_PASS thunder
MYSQL_DB thunder
#--------------------------------------------------|
# Settings para o Thunder
PORT 8080
TRANSPARENT false
DAEMON true
USER root
GROUP root
FORWARDED_IP false
X_FORWARDED_FOR false
BIND_ADDRESS 127.0.0.1
SERVERNUMBER 50
MAXSERVERS 1000
LOG_OKS false
LOGLEVEL 0
CACHE_LIMIT 60
ZPH_TOS_LOCAL 8
ORKUT_NORESUME true
ORKUT_NODOWN true
#--------------------------------------------------|
# Extensões
JPG_MIN 1000
JPG_MAX 0
JPG_EXP 86400
JPEG_MIN 1000
JPEG_MAX 0
JPEG_EXP 86400
GIF_MIN 1000
GIF_MAX 0
GIF_EXP 86400
FLV_MIN 1000
FLV_MAX 0
FLV_EXP 86400
WMV_MIN 1000
WMV_MAX 0
WMV_EXP 86400
WMA_MIN 1000
WMA_MAX 0
WMA_EXP 86400
RMVB_MIN 1000
RMVB_MAX 0
RMVB_EXP 86400
MPG_MIN 1000
MPG_MAX 0
MPG_EXP 86400
MPEG_MIN 1000
MPEG_MAX 0
MPEG_EXP 86400
AVI_MIN 1000
AVI_MAX 0
AVI_EXP 86400
SWF_MIN 1000
SWF_MAX 0
SWF_EXP 86400
DOC_MIN 1000
DOC_MAX 0
DOC_EXP 86400
DOCX_MIN 1000
DOCX_MAX 0
DOCX_EXP 86400
ZIP_MIN 1000
ZIP_MAX 0
ZIP_EXP 86400
RAR_MIN 1000
RAR_MAX 0
RAR_EXP 86400
EXE_MIN 1000
EXE_MAX 0
EXE_EXP 86400
PPT_MIN 1000
PPT_MAX 0
PPT_EXP 86400
PDF_MIN 1000
PDF_MAX 0
PDF_EXP 86400
#--------------------------------------------------|
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2008-2009 Thunder Cache
*
* For more information check http://thundercache.org
*
* Get relatories from system
*
* @author Joaquim Pedro (osmano807) <osmano807@gmail.com>
modified by Rodrigo Manga
*/
error_reporting(0);
$cache_dir = "/partition/thunder/cache";
//if (!( $db = new PDO('mysql:host=127.0.0.1;dbname=thunder', 'root','thundercache') ) ) {
// die("Não consegui conectar no database");
//}
$db=mysql_connect('127.0.0.1', 'thunder', 'thunder');
mysql_select_db('thunder',$db);
function disk_use($dir){
$df = disk_free_space($dir);
$dt = disk_total_space($dir);
$du = $dt-$df;
return ($du / $dt)*100;
}
function sizeFormat($size){
if($size<1024)
{
return $size." bytes";
}
else if($size<(1024*1024))
{
$size=round($size/1024,1);
return $size." KiB";
}
else if($size<(1024*1024*1024))
{
$size=round($size/(1024*1024),1);
return $size." MiB";
}
else
{
$size=round($size/(1024*1024*1024),1);
return $size." GiB";
}
}
$totaleconomy = $totalhits = $totalcount = $totalsize = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Relatorio Thunder Cache</title>
<style type="text/css">
<!--
table {
border: 1px solid #333333;
border-collapse:collapse;
height:20px;
text-align:center;
text-transform: none;
}
td {
padding-right: 30px;
padding-left: 30px;
height:20px;
}
tr {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
text-decoration: none;
height:25px;
}
.cabecalho {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
color: #FFFFFF;
text-decoration: none;
height:25px;
background-color: #666666;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
text-align:center;
}
-->
</style>
</head>
<body>
<div align="center"><font color="#0C70EE"><strong>Relatório do Sistema Thunder Cache 3:</strong><br />
</font><br />
<strong>Data de geração: <?= date(DATE_RFC822) ?>
<br>
Uso do disco: <?= round(disk_use($cache_dir),2) ?> %
</strong></div><br>
<table border="1" align="center">
<tr class="cabecalho">
<td><strong>Domínio</strong></td>
<td><strong>Arquivos</strong></td>
<td><strong>Tamanho</strong></td>
<td><strong>Economia</strong></td>
<td><strong>Hits</strong></td>
<td><strong>Eficiência %</strong></td></tr>
<?
global $db;
$query = "select domain,COUNT(*) as files,sum(size) as size,sum(size*requested) as eco, sum(requested) as hits from thunder where deleted=0 and static=0 group by domain UNION select 'static' as domain,COUNT(*) as files,sum(size) as size,sum(size*requested) as eco, sum(requested) as hits from thunder where deleted=0 and static=1";
$result=mysql_query($query,$db);
while($valor=mysql_fetch_array($result))
{
$percent=round(($valor['eco']/$valor['size'])*100,2)
?>
<tr>
<td height="18"><font color="#20A253">
<?= $valor['domain'] ?>
</font></td>
<td height="18"><font color="#20A253"><?= $valor['files'] ?></font></td>
<td height="18"><font color="#20A253"><?= sizeFormat($valor['size']) ?></font></td>
<td height="18"><font color="#20A253"><?= sizeFormat($valor['eco']) ?></font></td>
<td height="18"><font color="#20A253"><?= $valor['hits'] ?></font></td>
<td height="18"><font color="#20A253"><?= $percent ?> %</td></tr>
<?
$totaleconomy += $valor['eco'];
$totalhits += $valor['hits'];
$totalcount += $valor['files'];
$totalsize += $valor['size'];
}
?>
<tr><td height="22"><b><font color="#0C70EE">Total</font></b></td>
<td height="22"><b><font color="#0C70EE"><?= $totalcount ?></font></b></td>
<td height="22"><b><font color="#0C70EE"><?= sizeFormat($totalsize) ?></font></b></td>
<td height="22"><b><font color="#0C70EE"><?= sizeFormat($totaleconomy) ?></font></b></td>
<td height="22"><b><font color="#0C70EE"><?= $totalhits ?></font></b></td>
<td height="22"><b><font color="#0C70EE"><?= round(($totaleconomy/$totalsize)*100,3) ?> %</font></b></td></tr>
</table><br>
<table border="1" align="center"><tr><td align="left"<pre>
<?php system("free -om"); ?>
</pre></td></tr></table><br>
<table border="1" align="center"><tr><td align="left"><pre>
<?php system("uptime"); ?></td>
</pre></td></tr></table><br>
<table border="1" align="center"><tr><td align="left"><pre>
<?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?>
</pre></td></tr></table>
</body>
</html>
ENABLE_THUNDER='yes'
menuitem "ThunderCache" "/thunder" "/icons/thunder.png"
/usr/local/sbin/thunder
/etc/init.d/thunder
/etc/thunder/*
/etc/thunder/plugins/*
/var/htdocs/addons-menu/thunder.menu
/var/htdocs/webadmin/thunder/index.php
/var/htdocs/webadmin/icons/thunder.png
/var/addon-list/thundercache.pkg
/partition/mysql
/mnt
/etc/brazilfw/thunder
/partition/thunder
get-pkg /users/luapufo/thunder/install
/mnt
wget http://www.brazilfw.com.br/users/luapufo/thunder/webaux.bfw -P /mnt
/*
by brunovescovi - 06/11/2010 (brunovescovi at bol com br)
Remove toda a referência do thundercache no mysql, deixando pronto para uma instalação nova
*/
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI';
DROP PROCEDURE IF EXISTS `thunder`.`drop_user_if_exists` ;
DELIMITER $$
CREATE PROCEDURE `thunder`.`drop_user_if_exists`()
BEGIN
DECLARE jaexiste BIGINT DEFAULT 0 ;
SELECT COUNT(*)
INTO jaexiste
FROM `mysql`.`user`
WHERE `user` = 'thunder' ;
IF jaexiste > 0 THEN
DROP DATABASE IF EXISTS `thunder` ;
DROP USER 'thunder'@'127.0.0.1' ;
END IF;
END ;$$
DELIMITER ;
CALL `thunder`.`drop_user_if_exists`() ;
DROP PROCEDURE IF EXISTS `thunder`.`drop_users_if_exists` ;
SET SQL_MODE=@OLD_SQL_MODE ;
/* Isso resolve o problema de excluir o usuário se já existir um no mesmo nome
*/
/*
by brunovescovi - 06/11/2010 (brunovescovi at bol com br)
Remove toda a referência do thundercache no mysql, deixando pronto para uma instalação nova
*/
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI';
DROP PROCEDURE IF EXISTS `mysql`.`drop_thunder_if_exists` ;
DELIMITER $$
CREATE PROCEDURE `mysql`.`drop_thunder_if_exists`()
BEGIN
DECLARE jaexiste BIGINT DEFAULT 0 ;
SELECT COUNT(*)
INTO jaexiste
FROM `mysql`.`user`
WHERE `user` = 'thunder' ;
IF jaexiste > 0 THEN
DROP DATABASE IF EXISTS `thunder` ;
DROP USER 'thunder'@'127.0.0.1' ;
END IF;
END ;$$
DELIMITER ;
CALL `mysql`.`drop_thunder_if_exists`() ;
DROP PROCEDURE IF EXISTS `mysql`.`drop_thunder_if_exists` ;
SET SQL_MODE=@OLD_SQL_MODE ;
/* Isso resolve o problema de excluir o usuário se já existir um no mesmo nome
*/
CREATE USER 'thunder'@'127.0.0.1' IDENTIFIED BY 'thunder';
GRANT USAGE ON * . * TO 'thunder'@'127.0.0.1' IDENTIFIED BY 'thunder' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `thunder` ;
GRANT ALL PRIVILEGES ON `thunder` . * TO 'thunder'@'127.0.0.1';
FLUSH PRIVILEGES ;
USE `thunder`;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `thunder` (
`id` bigint(255) NOT NULL auto_increment,
`file` varchar(745) NOT NULL,
`domain` varchar(255) NOT NULL,
`size` int(10) unsigned NOT NULL default '0',
`modified` datetime NOT NULL,
`downloaded` datetime NOT NULL,
`requested` int(10) unsigned NOT NULL default '0',
`last_request` datetime NOT NULL,
`deleted` tinyint(1) NOT NULL default '0',
`static` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `file_domain` (`file`,`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Lano escreveu: optei por tentar utilizar uma estrutura parecida com a dos outros adons já existentes.
Lano escreveu:os arquivos não se perdem, pois eles acabam sendo repostos a cada reboot.
Voltar para BrazilFW 3.x - Ajuda em Geral
Usuários navegando neste fórum: Nenhum usuário registrado e 24 visitantes