From: Greg Burri Date: Thu, 24 Jul 2008 08:14:21 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 1.1.0~59 X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=commitdiff_plain;h=427ee8d1072dde4b06fbf019033c56e4929ee0d6 --- diff --git a/tools/tool.rb b/tools/tool.rb deleted file mode 100644 index fe7eb9d..0000000 --- a/tools/tool.rb +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/ruby -=begin -Copyright 2008 Grégory Burri - -This file is part of Euphorik. - -Euphorik 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 3 of the License, or -(at your option) any later version. - -Euphorik 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Euphorik. If not, see . -=end - -#TODO : -# - mettre à jour les numéros de versions en appelant le script "cope_num_version.rb" -# - création de unit tests (voir eunit) et validation avant la mise en prod - -class MiseEnProd - @@rep_remote = '/var/www/euphorik' - @@host = 'euphorik.ch' - @@opt_rsync = '' - - def initialize - end - - def creer_remote_rep(rep) - begin - `ssh #{@@host} "mkdir #{@@rep_remote}/#{rep}"` - rescue - end - end - - def compiler_partie_serveuse - Dir.chdir(@@rep_remote + '/modules') - puts `make` - if $?.exitstatus != 0 - puts "Echec de compilation de la partie serveuse" - exit 1 - end - Dir.chdir('..') - end - - def creer_repertoire_bd - # création du repertoire BD - creer_remote_rep('BD') - creer_remote_rep('BD/backup') - `ssh #{@@host} "chmod g+w #{@@rep_remote}/BD"` - end - - # css, images, html, etc.. - def copier_partie_statique - print `rsync #{$opt_rsync} index.yaws #{$host}:#{$rep_remote}` - print `rsync #{$opt_rsync} favicon.ico #{$host}:#{$rep_remote}` - print `rsync #{$opt_rsync} -r css #{$host}:#{$rep_remote}` - print `rsync #{$opt_rsync} -r pages #{$host}:#{$rep_remote}` - print `rsync #{$opt_rsync} -r --exclude 'autres' img #{$host}:#{$rep_remote}` - end - - # contrôle des fichiers js à l'aide de jslint - # @return false si une erreur est survenue durant la vérification - def check_js - - end - - # minification et package des fichiers js dans euphorik.js - def pack_js - # copie des js avec minification - rep_js = 'js' - creer_remote_rep(rep_js) - Dir.entries(rep_js).each{|fichier| - if fichier[0..0] != '.' and fichier != 'debug.js' - puts "Minimisation et copie de #{fichier}" - print `tools/jsmin.rb < #{rep_js}/#{fichier} | ssh #{@@host} "cat > #{@@rep_remote}/#{rep_js}/#{fichier}"` - end - } - end - - def copie_modules_serveurs - # copie des modules erlang - creer_remote_rep('modules') - `rsync #{@@opt_rsync} -r --exclude 'euphorik_test.beam' modules/ebin #{@@host}:#{@@rep_remote}/modules` - `rsync #{@@opt_rsync} -r modules/include #{@@host}:#{@@rep_remote}/modules` - end - - def set_droits_fichiers - # attribution des droits - `ssh #{$host} "chmod -R g+rx #{$rep_remote}"` - end - - def maj - # execution du script de mise à jour - print `cat tools/mise_en_prod.erl | ssh #{$host} "cat > /tmp/mise_en_prod.erl"` - print `ssh #{$host} "chmod u+x /tmp/mise_en_prod.erl; /tmp/mise_en_prod.erl; rm /tmp/mise_en_prod.erl"` - end -end diff --git a/tools/tools.rb b/tools/tools.rb new file mode 100644 index 0000000..fe7eb9d --- /dev/null +++ b/tools/tools.rb @@ -0,0 +1,102 @@ +#!/usr/bin/ruby +=begin +Copyright 2008 Grégory Burri + +This file is part of Euphorik. + +Euphorik 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 3 of the License, or +(at your option) any later version. + +Euphorik 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Euphorik. If not, see . +=end + +#TODO : +# - mettre à jour les numéros de versions en appelant le script "cope_num_version.rb" +# - création de unit tests (voir eunit) et validation avant la mise en prod + +class MiseEnProd + @@rep_remote = '/var/www/euphorik' + @@host = 'euphorik.ch' + @@opt_rsync = '' + + def initialize + end + + def creer_remote_rep(rep) + begin + `ssh #{@@host} "mkdir #{@@rep_remote}/#{rep}"` + rescue + end + end + + def compiler_partie_serveuse + Dir.chdir(@@rep_remote + '/modules') + puts `make` + if $?.exitstatus != 0 + puts "Echec de compilation de la partie serveuse" + exit 1 + end + Dir.chdir('..') + end + + def creer_repertoire_bd + # création du repertoire BD + creer_remote_rep('BD') + creer_remote_rep('BD/backup') + `ssh #{@@host} "chmod g+w #{@@rep_remote}/BD"` + end + + # css, images, html, etc.. + def copier_partie_statique + print `rsync #{$opt_rsync} index.yaws #{$host}:#{$rep_remote}` + print `rsync #{$opt_rsync} favicon.ico #{$host}:#{$rep_remote}` + print `rsync #{$opt_rsync} -r css #{$host}:#{$rep_remote}` + print `rsync #{$opt_rsync} -r pages #{$host}:#{$rep_remote}` + print `rsync #{$opt_rsync} -r --exclude 'autres' img #{$host}:#{$rep_remote}` + end + + # contrôle des fichiers js à l'aide de jslint + # @return false si une erreur est survenue durant la vérification + def check_js + + end + + # minification et package des fichiers js dans euphorik.js + def pack_js + # copie des js avec minification + rep_js = 'js' + creer_remote_rep(rep_js) + Dir.entries(rep_js).each{|fichier| + if fichier[0..0] != '.' and fichier != 'debug.js' + puts "Minimisation et copie de #{fichier}" + print `tools/jsmin.rb < #{rep_js}/#{fichier} | ssh #{@@host} "cat > #{@@rep_remote}/#{rep_js}/#{fichier}"` + end + } + end + + def copie_modules_serveurs + # copie des modules erlang + creer_remote_rep('modules') + `rsync #{@@opt_rsync} -r --exclude 'euphorik_test.beam' modules/ebin #{@@host}:#{@@rep_remote}/modules` + `rsync #{@@opt_rsync} -r modules/include #{@@host}:#{@@rep_remote}/modules` + end + + def set_droits_fichiers + # attribution des droits + `ssh #{$host} "chmod -R g+rx #{$rep_remote}"` + end + + def maj + # execution du script de mise à jour + print `cat tools/mise_en_prod.erl | ssh #{$host} "cat > /tmp/mise_en_prod.erl"` + print `ssh #{$host} "chmod u+x /tmp/mise_en_prod.erl; /tmp/mise_en_prod.erl; rm /tmp/mise_en_prod.erl"` + end +end