CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmd_enter.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_PUBLISH_CMD_ENTER_H_
6 #define CVMFS_PUBLISH_CMD_ENTER_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "publish/command.h"
12 #include "publish/settings.h"
13 
14 namespace publish {
15 
16 class SettingsPublisher;
17 
18 class CmdEnter : public Command {
19  public:
21  : settings_spool_area_("unset") // will be set by SetSpoolArea in Main()
22  , cvmfs2_binary_("/usr/bin/cvmfs2")
23  , overlayfs_binary_("/usr/bin/fuse-overlayfs") { }
24  virtual std::string GetName() const { return "enter"; }
25  virtual std::string GetBrief() const {
26  return "Open an ephemeral namespace to publish content";
27  }
28  virtual std::string GetUsage() const {
29  return "[options] <fully qualified repository name> [-- <command> "
30  "<params>]";
31  }
32  virtual ParameterList GetParams() const {
33  ParameterList p;
34  p.push_back(
35  Parameter::Optional("stratum0", 'w', "stratum0 url",
36  "HTTP endpoint of the authoritative storage"));
37  p.push_back(Parameter::Optional("cvmfs2", 'c', "path",
38  "Path to the cvmfs2 binary"));
39  p.push_back(Parameter::Optional(
40  "cvmfs-config", 'C', "path",
41  "Path to extra configuration for the CernVM-FS client"));
42  p.push_back(Parameter::Switch("root", 'r', "Run as fake root"));
43  p.push_back(Parameter::Switch(
44  "keep-session", 'k',
45  "Do not remove the session directory when the shell exits"));
46  p.push_back(Parameter::Switch(
47  "keep-logs", 'l',
48  "Clean the session directory on shell exit except for the logs"));
49  p.push_back(Parameter::Switch(
50  "transaction", 't', "Open a transaction within the ephemeral shell"));
51  p.push_back(
52  Parameter::Optional("repo-config", 'x', "repository configuration",
53  "Path to the configuration of the repository as in "
54  "/etc/cvmfs/repositories.d"));
55  return p;
56  }
57  virtual unsigned GetMinPlainArgs() const { return 1; }
58 
59  virtual int Main(const Options &options);
60 
61  private:
62  void MountOverlayfs();
63  void CreateUnderlay(const std::string &source_dir,
64  const std::string &dest_dir,
65  const std::vector<std::string> &empty_dirs,
66  std::vector<std::string> *new_paths);
67  void WriteCvmfsConfig(const std::string &extra_config);
68  void MountCvmfs();
69  pid_t RunInteractiveShell();
70 
71  std::string GetCvmfsXattr(const std::string &name);
72  void CleanupSession(bool keep_logs,
73  const std::vector<std::string> &new_paths);
74 
76  std::string fqrn_;
77  std::string cvmfs2_binary_;
78  std::string repo_config_;
79  std::string overlayfs_binary_;
80  std::string session_dir_;
81  std::string env_conf_;
82  std::string rootfs_dir_;
83  std::string stdout_path_;
84  std::string stderr_path_;
85 };
86 
87 } // namespace publish
88 
89 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
std::string session_dir_
In $HOME/.cvmfs/fqrn, container spool area.
Definition: cmd_enter.h:80
std::string stderr_path_
Logs stdout of background commands.
Definition: cmd_enter.h:84
static Parameter Optional(const std::string &key, char short_key, const std::string &arg_name, const std::string &desc)
Definition: command.h:69
virtual std::string GetUsage() const
Definition: cmd_enter.h:28
virtual ParameterList GetParams() const
Definition: cmd_enter.h:32
SettingsSpoolArea settings_spool_area_
Definition: cmd_enter.h:75
virtual int Main(const Options &options)
Definition: cmd_enter.cc:463
std::string cvmfs2_binary_
Definition: cmd_enter.h:77
pid_t RunInteractiveShell()
static Parameter Switch(const std::string &key, char short_key, const std::string &desc)
Definition: command.h:74
void WriteCvmfsConfig(const std::string &extra_config)
Definition: cmd_enter.cc:253
std::string overlayfs_binary_
Definition: cmd_enter.h:79
virtual std::string GetName() const
Definition: cmd_enter.h:24
std::vector< Parameter > ParameterList
Definition: command.h:86
std::string rootfs_dir_
Destination to chroot() to in the namespace.
Definition: cmd_enter.h:82
virtual std::string GetBrief() const
Definition: cmd_enter.h:25
void CleanupSession(bool keep_logs, const std::vector< std::string > &new_paths)
Definition: cmd_enter.cc:395
std::string GetCvmfsXattr(const std::string &name)
Definition: cmd_enter.cc:383
std::string env_conf_
Stores the session directory environment.
Definition: cmd_enter.h:81
virtual unsigned GetMinPlainArgs() const
Definition: cmd_enter.h:57
std::string fqrn_
Definition: cmd_enter.h:76
void MountOverlayfs()
Definition: cmd_enter.cc:338
std::string stdout_path_
Logs stdout of background commands.
Definition: cmd_enter.h:83
void CreateUnderlay(const std::string &source_dir, const std::string &dest_dir, const std::vector< std::string > &empty_dirs, std::vector< std::string > *new_paths)
Definition: cmd_enter.cc:156
std::string repo_config_
Definition: cmd_enter.h:78