Skip to content

Commit

Permalink
Add some tools to push and pull changes into my web space.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaputo committed May 24, 2009
1 parent be198ef commit 4332ecf
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
45 changes: 45 additions & 0 deletions extras/wiki/utils/get-changes.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env perl

use warnings;
use strict;

foreach my $source (
qw(
/Users/troc/Sites/poeperlorg
/var/www/poeperlorg
)
) {
next unless -d $source;

copy_files(
$source,
qw(
favicon.ico
global.css
robots.txt
dot-htaccess
data/templates/*.tt2
index.cgi
)
);
}

exit;

sub copy_files {
my ($source, @files) = @_;

foreach my $file (@files) {

my $source_file = $file;
$source_file =~ s/^dot-/./;

my $source_path = "$source/$source_file";

my $target = "./$file";
$target =~ s/\/[^\/]*$//;

my $cmd = "/bin/cp $source_path $target";
system $cmd and die $!;
}
}
85 changes: 85 additions & 0 deletions extras/wiki/utils/install.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env perl

use warnings;
use strict;

use constant VERBOSE => 1;

foreach my $target (
qw(
/Users/troc/Sites/poeperlorg
/var/www/poeperlorg
)
) {
next unless -d $target;

copy_644(
$target,
qw(
favicon.ico
global.css
robots.txt
dot-htaccess
data/templates/*.tt2
)
);

copy_755(
$target,
qw(
index.cgi
)
);
}

exit;

sub copy_files {
my ($target, @files) = @_;

foreach my $file (@files) {
my $target_file = $file;

my ($target_path) = ($file =~ /^(.*)\//);
if (defined $target_path) {
$target_path = "/$target_path";
}
else {
$target_path = "";
}

if (-f $file) {
$target_file =~ s/^dot-/./;
$target_path .= "/$target_file";
}

my $cmd = "/bin/cp $file $target$target_path";
VERBOSE and print "$cmd\n";
system $cmd and die $!;
}
}

sub chmod_files {
my ($mode, $target, @files) = @_;

foreach my $file (@files) {
(-f $file) and ($file =~ s/^dot-/./);
my $cmd = "/bin/chmod $mode $target/$file";
VERBOSE and print "$cmd\n";
system $cmd and die $!;
}
}

sub copy_644 {
my ($target, @files) = @_;

copy_files($target, @files);
chmod_files('0644', $target, @files);
}

sub copy_755 {
my ($target, @files) = @_;

copy_files($target, @files);
chmod_files('0755', $target, @files);
}

0 comments on commit 4332ecf

Please sign in to comment.