BCC admins@ instead of docelic@ in quota check
[clinton/scripts.git] / rsync-shell
CommitLineData
5213ef17 1#!/usr/bin/perl
2
3use strict;
4use warnings FATAL => 'all';
5
6use constant LOGFILE => '/var/log/rsync-shell.log';
7
8my %commands = (
9 "backup" => \&backup,
10 "rsync" => \&rsync,
11);
12
13sub backup {
14 exec '/usr/bin/sudo',
15 '/afs/hcoop.net/common/etc/scripts/hcoop-backup-wrapper';
16}
17
18sub rsync {
19 my ($cmdline) = @_;
20
f1a20ec8 21 if ( $cmdline !~ m!^--server --sender -vre\.iL --bwlimit=325 \. /vicepa/hcoop-backups/files/[0-9]{4}\.[0-9]{2}\.[0-9]{2}$!s ) {
5213ef17 22 die "Incorrect arguments to rsync.\n";
23 }
24
25 exec '/usr/bin/rsync', split(' ', $cmdline)
26 or die "Could not run rsync command.\n";
27}
28
29sub main {
30 -f LOGFILE && open (LOG, '>>', LOGFILE)
31 or die "Can't open log file.\n";
32
33 print LOG "Session started on ", `date`;
34 print LOG "Commands: ", map { "<$_> " } @ARGV;
35 print LOG "\n";
36
37 $ARGV[1] =~ /^([^ ]+) *(.*?)$/s;
38 my $cmd = $commands{$1}
39 or die "Unsupported command.\n";
40
41 $cmd->($2);
42}
43
44main()
45