initial commit of file from CVS for smeserver-subversion on Sat Sep 7 16:43:25 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 16:43:25 +10:00
parent 05f1f98a63
commit b1c12018e8
52 changed files with 7234 additions and 2 deletions

View File

@@ -0,0 +1,50 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# vim: ts=4 sw=4 et:
#----------------------------------------------------------------------
# This file is part of the "Subversion repositories" panel in the
# SME Server server-manager panel to configure subversion repositories.
#
# 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 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
#----------------------------------------------------------------------
#------------------------------------------------------------
# Delete the files for the repository.
#------------------------------------------------------------
use strict;
use Errno;
use File::Path;
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro();
my $event = $ARGV [0];
my $repository = $ARGV [1];
$a = $adb->get($repository) || undef;
unless ( defined $a && $a->prop('type') eq "repository-deleted" )
{
warn "$repository is not a repository\n";
exit (0);
}
my $dir = "/home/e-smith/files/repositories/$repository";
exit 0 unless ( -d $dir );
rmtree( $dir ) || die "Couldn't remove tree $dir\n";
exit (0);

View File

@@ -0,0 +1,75 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# $Id
# vim: ft=perl ts=4 sw=4 et:
#----------------------------------------------------------------------
# $Copyright
#
# This file is part of the "Subversion repositories" panel in the
# SME Server server-manager panel to configure subversion repositories.
#
# 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 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
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use File::Find;
use esmith::util;
use esmith::templates;
use esmith::AccountsDB;
use esmith::ConfigDB;
$ENV{'PATH'} = "/bin";
my $event = $ARGV [0];
my $repositoryName = $ARGV [1];
die "repositoryName argument missing" unless defined ($repositoryName);
my $accountdb = esmith::AccountsDB->open_ro();
my $repository = $accountdb->get($repositoryName) or
die "Couldn't find $repositoryName record in accounts db\n";
die "Account $repositoryName is not an repository account; modify repository event failed.\n"
unless ($repository->prop('type') eq 'repository');
if ($event eq 'repository-create')
{
#------------------------------------------------------------
# Create the repository files
#------------------------------------------------------------
system("/usr/bin/svnadmin", "create",
"/home/e-smith/files/repositories/$repositoryName") == 0
or die "Error copying repository skeletal files";
}
elsif ($event eq 'repository-modify')
{
}
#------------------------------------------------------------
# Fix permissions on repository files.
#------------------------------------------------------------
chdir "/home/e-smith/files/repositories/$repositoryName"
or die "Could not chdir to /home/e-smith/files/repositories/$repositoryName";
system("/bin/chown", "-R", "www:www", "/home/e-smith/files/repositories/$repositoryName") == 0
or die "Could not change ownership of /home/e-smith/files/repositories/$repositoryName";
chmod 0755, ".";

View File

@@ -0,0 +1,58 @@
#!/usr/bin/perl -w
package esmith;
use strict;
use Errno;
use esmith::util;
my $event = $ARGV [0];
my $item = $ARGV [1];
#------------------------------------------------------------
# Delete the user from subversion repositories
#------------------------------------------------------------
die "Username argument missing." unless defined ($item);
my @entries = qw();
if ($event eq 'user-delete') {
@entries = qw(UsersWrite UsersRead);
} elsif ($event eq 'group-delete') {
@entries = qw(GroupsWrite GroupsRead);
} else {
die "Invalid event: $event";
}
use esmith::AccountsDB;
my $db_accounts = esmith::AccountsDB->open() or
die "Couldn't open AccountsDB\n";
my @repositories = $db_accounts->get_all_by_prop('type' => 'repository');
REPOSITORY: foreach my $repository (
(@repositories),
)
{
my $repository_rec = $db_accounts->get($repository->key()) || next REPOSITORY;
foreach my $entry (@entries) {
my $members = $repository_rec->prop($entry);
my @members = split (/,/, $members);
@members = grep (!/^$item$/, @members);
$repository_rec->set_prop($entry, join(',', @members));
}
}
exit(0);