[vhffs-dev] [1985] almost removed Vhffs::Functions::hash_webdir(), still need to do robots which use another basename |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [1985] almost removed Vhffs::Functions::hash_webdir(), still need to do robots which use another basename
- From: subversion@xxxxxxxxxxxxx
- Date: Wed, 01 Feb 2012 00:12:02 +0100
Revision: 1985
Author: gradator
Date: 2012-02-01 00:12:01 +0100 (Wed, 01 Feb 2012)
Log Message:
-----------
almost removed Vhffs::Functions::hash_webdir(), still need to do robots which use another basename
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Constants.pm
trunk/vhffs-api/src/Vhffs/Robots/Web.pm
trunk/vhffs-api/src/Vhffs/Services/Web.pm
trunk/vhffs-api/src/examples/Makefile.am
trunk/vhffs-tools/src/vhffs-webdir
Removed Paths:
-------------
trunk/vhffs-api/src/examples/hash_webdir.pl
Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm 2012-01-31 23:12:01 UTC (rev 1985)
@@ -33,9 +33,6 @@
USER_ADMIN => 1,
USER_MODERATOR => 2,
- HOMEDIR => "web/",
- WEBDIR => "web/",
- CVSDIR => "cvs/",
REPOSITORYDIR => "repository/",
WEB_SUFFIX => "-web",
@@ -187,10 +184,6 @@
=head2 ML_RIGHT_SUB_WAITING_FOR_DEL
-=head2 WEBDIR
-
-=head2 CVSDIR
-
=head2 USER_NORMAL
=head2 USER_ADMIN
Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-01-31 23:12:01 UTC (rev 1985)
@@ -49,17 +49,18 @@
if( defined $web )
{
$web->add_history( "Ok, the robot take the creation of this object. Web directory will be created");
- my $webdir = $main->get_config->get_datadir . "/" . Vhffs::Constants::WEBDIR . "/" . Vhffs::Functions::hash_webdir( $web->get_servername );
-
+ my $webdir = $web->get_dir;
+
Vhffs::Functions::create_dir( $webdir );
-# chown( $web->get_owner_uid , $web->get_owner_gid , $webdir );
+
Vhffs::Functions::create_dir( $webdir . "/htdocs");
chown( $web->get_owner_uid , $web->get_owner_gid , $webdir . "/htdocs" );
chmod( 02775 , $webdir . "/htdocs" );
- Vhffs::Functions::create_dir( $webdir . "/php-include");
+ Vhffs::Functions::create_dir( $webdir . "/php-include");
chown( $web->get_owner_uid , $web->get_owner_gid , $webdir . "/php-include" );
chmod( 02775 , $webdir . "/php-include" );
+
Vhffs::Functions::create_dir( $webdir . "/tmp");
chown( $web->get_owner_uid , $web->get_owner_gid , $webdir . "/tmp" );
chmod( 02775 , $webdir . "/tmp" );
@@ -91,12 +92,7 @@
if(defined $web)
{
$web->add_history( "Ok, the robot will delete this object. Web directory will be removed");
- my $hash = Vhffs::Functions::hash_webdir( $web->get_servername );
-
- return -1 if( ( ! defined $hash ) || ( length( $hash ) < 2 ) );
-
- my $webdir = $main->get_config->get_datadir . "/" . Vhffs::Constants::WEBDIR . "/" . $hash ;
-
+ my $webdir = $web->get_dir;
my $group = $web->get_group;
if(Vhffs::Robots::unlink_from_group( $group,$web->get_servername.Vhffs::Constants::WEB_SUFFIX,$main) < 0)
{
Modified: trunk/vhffs-api/src/Vhffs/Services/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Web.pm 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-api/src/Vhffs/Services/Web.pm 2012-01-31 23:12:01 UTC (rev 1985)
@@ -118,7 +118,7 @@
=head2 get_servername
- my $servername = $httpd->getservername;
+ my $servername = $httpd->get_servername;
Returns webarea server name.
@@ -131,6 +131,21 @@
}
+=head2 get_dir
+
+ my $dir = $httpd->get_dir;
+
+Returns webarea directory.
+
+=cut
+
+sub get_dir {
+ my $self = shift;
+ require Digest::MD5;
+ my $hash = Digest::MD5::md5_hex( $self->{'servername'} );
+ return $self->{main}->get_config->get_datadir.'/web/'.substr( $hash, 0, 2 ).'/'.substr( $hash, 2, 2 ).'/'.substr( $hash, 4, 2 ).'/'.$self->{'servername'};
+}
+
=head2 get_label
See C<Vhffs::Object::get_label>.
Modified: trunk/vhffs-api/src/examples/Makefile.am
===================================================================
--- trunk/vhffs-api/src/examples/Makefile.am 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-api/src/examples/Makefile.am 2012-01-31 23:12:01 UTC (rev 1985)
@@ -23,7 +23,6 @@
delete_acl.pl \
generate_password.pl \
get_list.pl \
- hash_webdir.pl \
join_group.pl \
list_themes.pl \
mailuser_add_box.pl \
Deleted: trunk/vhffs-api/src/examples/hash_webdir.pl
===================================================================
--- trunk/vhffs-api/src/examples/hash_webdir.pl 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-api/src/examples/hash_webdir.pl 2012-01-31 23:12:01 UTC (rev 1985)
@@ -1,8 +0,0 @@
-#!%PERL%
-
-use strict;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Functions;
-
-print Vhffs::Functions::hash_webdir( "zozo.tata.com" );
Modified: trunk/vhffs-tools/src/vhffs-webdir
===================================================================
--- trunk/vhffs-tools/src/vhffs-webdir 2012-01-31 20:56:47 UTC (rev 1984)
+++ trunk/vhffs-tools/src/vhffs-webdir 2012-01-31 23:12:01 UTC (rev 1985)
@@ -3,35 +3,27 @@
##############################################################################
# This binary change directory to the specified website passed trough argument
# This is a part of VHFFS distribution
-# Use as it : webdir toto.tuxfamily.org
+# Use as it : vhffs-webdir vhffs.org
use strict;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Main;
-use Vhffs::Constants;
-use Vhffs::Functions;
+use Vhffs::Services::Web;
-
-if( $#ARGV != 0 )
-{
- print "Error ! Exec this script as it : webdir your.web.site\n";
- print "Example : webdir tuxfamily.org\n";
- exit( -1 );
+if( $#ARGV != 0 ) {
+ print 'Error ! Exec this script as it : webdir your.web.site'."\n";
+ print 'Example : vhffs-webdir vhffs.org'."\n";
+ exit( -1 );
}
my $main = init Vhffs::Main;
-my $webdir = $main->get_config->get_datadir . "/" . Vhffs::Constants::WEBDIR . "/" . Vhffs::Functions::hash_webdir( $ARGV[0] );
-if( -d $webdir )
-{
- my $shell;
- print "Create new shell in $webdir\n";
- chdir($webdir);
- $shell = "/bin/bash";
- $shell = $ENV{'SHELL'} if( defined $ENV{'SHELL'} );
- system( $shell );
+exit 1 unless defined $main;
+
+my $web = Vhffs::Services::Web::get_by_servername( $main, $ARGV[0] );
+unless( defined $web ) {
+ print 'No such website'."\n";
+ exit 1;
}
-else
-{
- print "Directory does not exist\n";
- exit( -1 );
-}
+
+my $webdir = $web->get_dir;
+print $webdir."\n";