CernVM-FS  2.13.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  LogCvmfs(kLogCvmfs, kLogStdout, "Created by CernVM-FS %s",
37  creator_version.c_str());
38  } else {
40  "Configuration error: CVMFS_CREATOR_VERSION missing");
41  }
42  }
43  LogCvmfs(kLogCvmfs, kLogStdout, "Stratum1 replication allowed: %s",
44  repository.IsMasterReplica() ? "yes" : "no");
45  if (repository.whitelist()->IsExpired()) {
46  LogCvmfs(kLogCvmfs, kLogStdout, "Whitelist is expired");
47  } else {
48  double delta_s = difftime(repository.whitelist()->expires(), time(NULL));
49  int delta_d = static_cast<int>(delta_s / 86400);
50  LogCvmfs(kLogCvmfs, kLogStdout, "Whitelist is valid for another %d days",
51  delta_d);
52  }
53 
55  "\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(), settings.fqrn().c_str(),
62  settings.url().c_str(),
63  settings.keychain().master_public_key_path().c_str(),
64  settings.keychain().master_public_key_path().c_str());
65 
66  if (options.Has("meta-info")) {
67  LogCvmfs(kLogCvmfs, kLogStdout, "\nMeta info:\n%s",
68  repository.meta_info().c_str());
69  }
70 
71  return 0;
72 }
73 
74 } // namespace publish
SettingsKeychain * GetKeychain()
Definition: settings.h:373
void SetKeychainDir(const std::string &keychain_dir)
Definition: settings.cc:229
bool Has(const std::string &key) const
Definition: command.h:108
std::string GetString(const std::string &key) const
Definition: command.h:115
const SettingsPublisher & settings() const
Definition: repository.h:316
const std::vector< Argument > & plain_args() const
Definition: command.h:128
Repository(const SettingsRepository &settings, const bool exists=true)
Definition: repository.cc:49
std::string master_public_key_path() const
Definition: settings.h:326
bool IsManagedRepository() const
Definition: settings.h:516
SettingsRepository CreateSettingsRepository(const std::string &ident)
Definition: settings.cc:415
virtual int Main(const Options &options)
Definition: cmd_info.cc:20
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:368
OptionsManager * options_mgr() const
Definition: settings.h:515
const SettingsKeychain & keychain() const
Definition: settings.h:372
std::string fqrn() const
Definition: settings.h:366
std::string url() const
Definition: settings.h:367
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:545