Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 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,40 @@ | ||
#!/usr/bin/perl | ||
# | ||
# Trivial shrtn setup script, creating and populating initial data directory | ||
# | ||
|
||
use strict; | ||
use warnings; | ||
use File::Basename; | ||
use File::Copy; | ||
use FindBin qw($Bin); | ||
|
||
-d "$Bin/data" | ||
and die "Error: 'data' directory already exists - won't overwrite\n"; | ||
|
||
mkdir "$Bin/data" | ||
or die "Error: mkdir of 'data' directory failed: $!\n"; | ||
|
||
# Copy config.yml.dist and template.html.dist | ||
for my $f (glob("$Bin/conf/*ml.dist")) { | ||
my $from = basename($f); | ||
my $to = $from; | ||
$to =~ s/\.dist$//; | ||
|
||
print "cp conf/$from data/$to\n"; | ||
|
||
copy($f, "$Bin/data/$to") | ||
or die "copy failed: $!\n"; | ||
} | ||
|
||
# Ask/copy webserver configs | ||
for my $webserver (qw(apache nginx)) { | ||
print "Copy $webserver.conf.dist? [n] "; | ||
my $ans = <>; | ||
if ($ans && $ans =~ /^y/i) { | ||
print "cp conf/$webserver.conf.dist data/$webserver.conf\n"; | ||
copy("$Bin/conf/$webserver.conf.dist", "$Bin/data/$webserver.conf") | ||
or die "copy failed: $!\n"; | ||
} | ||
} | ||
|