CernVM-FS  2.12.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  { }
25  virtual std::string GetName() const { return "enter"; }
26  virtual std::string GetBrief() const {
27  return "Open an ephemeral namespace to publish content";
28  }
29  virtual std::string GetUsage() const {
30  return \
31  "[options] <fully qualified repository name> [-- <command> <params>]";
32  }
33  virtual ParameterList GetParams() const {
34  ParameterList p;
35  p.push_back(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("cvmfs-config", 'C', "path",
40  "Path to extra configuration for the CernVM-FS client"));
41  p.push_back(Parameter::Switch("root", 'r', "Run as fake root"));
42  p.push_back(Parameter::Switch("keep-session", 'k',
43  "Do not remove the session directory when the shell exits"));
44  p.push_back(Parameter::Switch("keep-logs", 'l',
45  "Clean the session directory on shell exit except for the logs"));
46  p.push_back(Parameter::Switch("transaction", 't',
47  "Open a transaction within the ephemeral shell"));
48  p.push_back(
49  Parameter::Optional("repo-config", 'x', "repository configuration",
50  "Path to the configuration of the repository as in "
51  "/etc/cvmfs/repositories.d"));
52  return p;
53  }
54  virtual unsigned GetMinPlainArgs() const { return 1; }
55 
56  virtual int Main(const Options &options);
57 
58  private:
59  void MountOverlayfs();
60  void CreateUnderlay(const std::string &source_dir,
61  const std::string &dest_dir,
62  const std::vector<std::string> &empty_dirs,
63  std::vector<std::string> *new_paths);
64  void WriteCvmfsConfig(const std::string &extra_config);
65  void MountCvmfs();
66  pid_t RunInteractiveShell();
67 
68  std::string GetCvmfsXattr(const std::string &name);
69  void CleanupSession(bool keep_logs,
70  const std::vector<std::string> &new_paths);
71 
73  std::string fqrn_;
74  std::string cvmfs2_binary_;
75  std::string repo_config_;
76  std::string overlayfs_binary_;
77  std::string session_dir_;
78  std::string env_conf_;
79  std::string rootfs_dir_;
80  std::string stdout_path_;
81  std::string stderr_path_;
82 };
83 
84 } // namespace publish
85 
86 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
std::string session_dir_
In $HOME/.cvmfs/fqrn, container spool area.
Definition: cmd_enter.h:77
std::string stderr_path_
Logs stdout of background commands.
Definition: cmd_enter.h:81
static Parameter Optional(const std::string &key, char short_key, const std::string &arg_name, const std::string &desc)
Definition: command.h:73
virtual std::string GetUsage() const
Definition: cmd_enter.h:29
virtual ParameterList GetParams() const
Definition: cmd_enter.h:33
SettingsSpoolArea settings_spool_area_
Definition: cmd_enter.h:72
virtual int Main(const Options &options)
Definition: cmd_enter.cc:469
std::string cvmfs2_binary_
Definition: cmd_enter.h:74
pid_t RunInteractiveShell()
static Parameter Switch(const std::string &key, char short_key, const std::string &desc)
Definition: command.h:79
void WriteCvmfsConfig(const std::string &extra_config)
Definition: cmd_enter.cc:255
std::string overlayfs_binary_
Definition: cmd_enter.h:76
virtual std::string GetName() const
Definition: cmd_enter.h:25
std::vector< Parameter > ParameterList
Definition: command.h:92
std::string rootfs_dir_
Destination to chroot() to in the namespace.
Definition: cmd_enter.h:79
virtual std::string GetBrief() const
Definition: cmd_enter.h:26
void CleanupSession(bool keep_logs, const std::vector< std::string > &new_paths)
Definition: cmd_enter.cc:400
std::string GetCvmfsXattr(const std::string &name)
Definition: cmd_enter.cc:388
std::string env_conf_
Stores the session directory environment.
Definition: cmd_enter.h:78
virtual unsigned GetMinPlainArgs() const
Definition: cmd_enter.h:54
std::string fqrn_
Definition: cmd_enter.h:73
void MountOverlayfs()
Definition: cmd_enter.cc:342
std::string stdout_path_
Logs stdout of background commands.
Definition: cmd_enter.h:80
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:75