Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
|
6 |
|
|
#include "cmd_info.h" |
7 |
|
|
|
8 |
|
|
#include <ctime> |
9 |
|
|
#include <string> |
10 |
|
|
|
11 |
|
|
#include "options.h" |
12 |
|
|
#include "publish/except.h" |
13 |
|
|
#include "publish/repository.h" |
14 |
|
|
#include "publish/settings.h" |
15 |
|
|
#include "util/logging.h" |
16 |
|
|
#include "whitelist.h" |
17 |
|
|
|
18 |
|
|
namespace publish { |
19 |
|
|
|
20 |
|
✗ |
int CmdInfo::Main(const Options &options) { |
21 |
|
✗ |
SettingsBuilder builder; |
22 |
|
|
SettingsRepository settings = builder.CreateSettingsRepository( |
23 |
|
✗ |
options.plain_args().empty() ? "" : options.plain_args()[0].value_str); |
24 |
|
|
|
25 |
|
✗ |
if (options.Has("keychain")) { |
26 |
|
✗ |
settings.GetKeychain()->SetKeychainDir(options.GetString("keychain")); |
27 |
|
|
} |
28 |
|
✗ |
Repository repository(settings); |
29 |
|
|
|
30 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "Repository name: %s", |
31 |
|
|
settings.fqrn().c_str()); |
32 |
|
✗ |
if (builder.IsManagedRepository()) { |
33 |
|
✗ |
std::string creator_version; |
34 |
|
✗ |
if (builder.options_mgr()->GetValue("CVMFS_CREATOR_VERSION", |
35 |
|
|
&creator_version)) |
36 |
|
|
{ |
37 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "Created by CernVM-FS %s", |
38 |
|
|
creator_version.c_str()); |
39 |
|
|
} else { |
40 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStderr, |
41 |
|
|
"Configuration error: CVMFS_CREATOR_VERSION missing"); |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "Stratum1 replication allowed: %s", |
45 |
|
|
repository.IsMasterReplica() ? "yes" : "no"); |
46 |
|
✗ |
if (repository.whitelist()->IsExpired()) { |
47 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "Whitelist is expired"); |
48 |
|
|
} else { |
49 |
|
✗ |
double delta_s = difftime(repository.whitelist()->expires(), time(NULL)); |
50 |
|
✗ |
int delta_d = static_cast<int>(delta_s / 86400); |
51 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "Whitelist is valid for another %d days", |
52 |
|
|
delta_d); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "\nClient configuration:\n" |
56 |
|
|
"Add %s to CVMFS_REPOSITORIES in /etc/cvmfs/default.local\n" |
57 |
|
|
"Create /etc/cvmfs/config.d/%s.conf and set\n" |
58 |
|
|
" CVMFS_SERVER_URL=%s\n" |
59 |
|
|
" CVMFS_PUBLIC_KEY=%s\n" |
60 |
|
|
"Copy %s to the client", |
61 |
|
|
settings.fqrn().c_str(), |
62 |
|
|
settings.fqrn().c_str(), |
63 |
|
|
settings.url().c_str(), |
64 |
|
|
settings.keychain().master_public_key_path().c_str(), |
65 |
|
|
settings.keychain().master_public_key_path().c_str()); |
66 |
|
|
|
67 |
|
✗ |
if (options.Has("meta-info")) { |
68 |
|
✗ |
LogCvmfs(kLogCvmfs, kLogStdout, "\nMeta info:\n%s", |
69 |
|
|
repository.meta_info().c_str()); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
✗ |
return 0; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
} // namespace publish |
76 |
|
|
|