#!/usr/bin/env perl
my
$site_dir
=
shift
;
my
$skel_dir
=
shift
;
die
"usage: $0 path/to/new-site-directory [path/to/skel]\n"
unless
$site_dir
;
die
qq[A file or directory named "$site_dir" already exists, will not overwrite.\n]
if
-e
$site_dir
;
my
$module_dir
=
$skel_dir
// module_dir(
'Yukki::Web'
);
my
@files
=
glob
"$module_dir/*"
;
$File::Copy::Recursive::KeepMode
= 0;
dircopy(
$module_dir
,
$site_dir
);
my
$root
= dir(
$site_dir
)->absolute;
my
$yaml
= file(
$root
,
'etc'
,
'yukki.conf'
);
rename
$yaml
,
"$yaml~"
;
open
my
$out_config
,
'>:encoding(UTF-8)'
,
$yaml
;
open
my
$in_config
,
'<:encoding(UTF-8)'
,
"$yaml~"
;
while
(
my
$line
= <
$in_config
>) {
if
(
$line
=~ /^root:/) {
$line
=
"root: $root\n"
;
}
print
$out_config
$line
;
}
close
$out_config
;
close
$in_config
;
unlink
"$yaml~"
;
chmod
0444,
"$yaml"
;
my
$config
= load_file(
$yaml
);
say
"Please read the installation instructions if you have not:\n"
;
say
"\tperldoc Yukki::Manual::Installation\n"
;
say
"The rest of these remarks assume you run this first:\n"
;
say
"\tcd $site_dir\n"
;
say
"You probably want to setup your repositories by running:\n"
;
for
(
sort
keys
%{
$config
->{repositories} }) {
else
{
say
"\tyukki-git-init $_"
}
}
print
"\n"
;
say
"And then you'll want at least one user, so run:\n"
;
say
"\tyukki-add-user\n"
;
say
"To start your Yukki server, run:\n"
;
say
"\tcd $site_dir; plackup yukki.psgi\n"
;
say
"Have a nice day!"
;