-
Notifications
You must be signed in to change notification settings - Fork 0
/
shrtn_setup
executable file
·39 lines (33 loc) · 1.09 KB
/
shrtn_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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
if (-f "conf/config.yml") {
print "conf/config.yml already exists - skipping\n";
}
else {
print "cp conf/config.yml.dist conf/config.yml\n";
copy("$Bin/conf/config.yml.dist", "$Bin/config/config.yml") or die "copy failed: $!\n";
}
print "cp conf/template.html.dist data/template.html\n";
copy("$Bin/conf/template.html.dist", "$Bin/data/template.html") 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";
}
}