You need domtool-admin rights to destroy a user
[clinton/scripts.git] / rsync-shell
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings FATAL => 'all';
5
6 use constant LOGFILE => '/var/log/rsync-shell.log';
7
8 my %commands = (
9 "backup" => \&backup,
10 "rsync" => \&rsync,
11 );
12
13 sub backup {
14 exec '/usr/bin/sudo',
15 '/afs/hcoop.net/common/etc/scripts/hcoop-backup-wrapper';
16 }
17
18 sub rsync {
19 my ($cmdline) = @_;
20
21 if ( $cmdline !~ m!^--server --sender -vre\.iL --bwlimit=325 \. /vicepa/hcoop-backups/files/[0-9]{4}\.[0-9]{2}\.[0-9]{2}$!s ) {
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
29 sub 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
44 main()
45