1 | #!/usr/bin/perl |
---|
2 | # ------------------------------------------------------------------------------ |
---|
3 | # (C) Crown copyright Met Office. All rights reserved. |
---|
4 | # For further details please refer to the file COPYRIGHT.txt |
---|
5 | # which you should have received as part of this distribution. |
---|
6 | # ------------------------------------------------------------------------------ |
---|
7 | |
---|
8 | use strict; |
---|
9 | use warnings; |
---|
10 | |
---|
11 | use FindBin; |
---|
12 | use lib "$FindBin::Bin/../lib"; |
---|
13 | use FCM::Admin::System qw{ |
---|
14 | filter_projects |
---|
15 | get_projects_from_trac_backup |
---|
16 | recover_trac_environment |
---|
17 | recover_trac_ini_file |
---|
18 | recover_trac_passwd_file |
---|
19 | }; |
---|
20 | use FCM::Admin::Util qw{option2config}; |
---|
21 | use Getopt::Long qw{GetOptions}; |
---|
22 | use Pod::Usage qw{pod2usage}; |
---|
23 | |
---|
24 | main(); |
---|
25 | |
---|
26 | sub main { |
---|
27 | my %option; |
---|
28 | my $result = GetOptions( |
---|
29 | \%option, |
---|
30 | q{help|usage|h}, |
---|
31 | q{no-ini-file}, |
---|
32 | q{no-passwd-file}, |
---|
33 | q{trac-backup-dir=s}, |
---|
34 | q{trac-live-dir=s}, |
---|
35 | q{trac-ini-file=s}, |
---|
36 | q{trac-passwd-file=s}, |
---|
37 | ); |
---|
38 | if (!$result) { |
---|
39 | pod2usage(1); |
---|
40 | } |
---|
41 | if (exists($option{help})) { |
---|
42 | pod2usage(q{-verbose} => 1); |
---|
43 | } |
---|
44 | option2config(\%option); |
---|
45 | my @projects = filter_projects([get_projects_from_trac_backup()], \@ARGV); |
---|
46 | for my $project (@projects) { |
---|
47 | recover_trac_environment($project); |
---|
48 | } |
---|
49 | if (!@ARGV && !exists($option{q{no-ini-file}})) { |
---|
50 | recover_trac_ini_file(); |
---|
51 | } |
---|
52 | if (!@ARGV && !exists($option{q{no-passwd-file}})) { |
---|
53 | recover_trac_passwd_file(); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | __END__ |
---|
58 | |
---|
59 | =head1 NAME |
---|
60 | |
---|
61 | fcm-recover-trac-env |
---|
62 | |
---|
63 | =head1 SYNOPSIS |
---|
64 | |
---|
65 | fcm-recover-trac-env [OPTIONS] [PROJECT ...] |
---|
66 | |
---|
67 | =head1 OPTIONS |
---|
68 | |
---|
69 | =over 4 |
---|
70 | |
---|
71 | =item --help, -h, --usage |
---|
72 | |
---|
73 | Prints help and exits. |
---|
74 | |
---|
75 | =item --no-ini-file |
---|
76 | |
---|
77 | Do not recover the (central) INI file. This option is automatic if one or more |
---|
78 | project name is specified in the argument list. |
---|
79 | |
---|
80 | =item --no-passwd-file |
---|
81 | |
---|
82 | Do not recover the password file. This option is automatic if one or more |
---|
83 | project name is specified in the argument list. |
---|
84 | |
---|
85 | =item --trac-backup-dir=DIR |
---|
86 | |
---|
87 | Specifies the root location of the backup directory. See |
---|
88 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
89 | |
---|
90 | =item --trac-ini-file=FILE |
---|
91 | |
---|
92 | Specifies the base name of the Trac INI file. See |
---|
93 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
94 | |
---|
95 | =item --trac-live-dir=DIR |
---|
96 | |
---|
97 | Specifies the root location of the live directory. See |
---|
98 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
99 | |
---|
100 | =item --trac-passwd-file=FILE |
---|
101 | |
---|
102 | Specifies the base name of the Trac password file. See |
---|
103 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
104 | |
---|
105 | =back |
---|
106 | |
---|
107 | =head1 ARGUMENTS |
---|
108 | |
---|
109 | =over 4 |
---|
110 | |
---|
111 | =item PROJECT |
---|
112 | |
---|
113 | Specifies one or more project to recover. If no project is specified, the |
---|
114 | program searches the backup directory for projects to recover. |
---|
115 | |
---|
116 | No attempt to recover the (central) INI file and the password file is made if |
---|
117 | one or more project name is specified. |
---|
118 | |
---|
119 | =back |
---|
120 | |
---|
121 | =head1 DESCRIPTION |
---|
122 | |
---|
123 | This program recovers Trac environments, the (central) INI file and the |
---|
124 | password file from the backup directory to the live directory. |
---|
125 | |
---|
126 | =head1 COPYRIGHT |
---|
127 | |
---|
128 | E<169> Crown copyright Met Office. All rights reserved. |
---|
129 | |
---|
130 | =cut |
---|