-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tools to push and pull changes into my web space.
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |