CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmd_info.cc
Go to the documentation of this file.
1 
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;
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 {
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
SettingsKeychain * GetKeychain()
Definition: settings.h:380
void SetKeychainDir(const std::string &keychain_dir)
Definition: settings.cc:239
bool Has(const std::string &key) const
Definition: command.h:114
std::string GetString(const std::string &key) const
Definition: command.h:123
const SettingsPublisher & settings() const
Definition: repository.h:317
const std::vector< Argument > & plain_args() const
Definition: command.h:137
Repository(const SettingsRepository &settings, const bool exists=true)
Definition: repository.cc:49
std::string master_public_key_path() const
Definition: settings.h:332
bool IsManagedRepository() const
Definition: settings.h:527
SettingsRepository CreateSettingsRepository(const std::string &ident)
Definition: settings.cc:442
virtual int Main(const Options &options)
Definition: cmd_info.cc:20
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:376
OptionsManager * options_mgr() const
Definition: settings.h:526
const SettingsKeychain & keychain() const
Definition: settings.h:379
std::string fqrn() const
Definition: settings.h:373
std::string url() const
Definition: settings.h:374
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:528