CernVM-FS  2.9.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 "[options] <fully qualified repository name> [-- <command> <parms>]";
31  }
32  virtual ParameterList GetParams() const {
33  ParameterList p;
34  p.push_back(Parameter::Optional("stratum0", 'w', "stratum0 url",
35  "HTTP endpoint of the authoritative storage"));
36  p.push_back(Parameter::Optional("cvmfs2", 'c', "path",
37  "Path to the cvmfs2 binary"));
38  p.push_back(Parameter::Optional("cvmfs-config", 'C', "path",
39  "Path to extra configuration for the CernVM-FS client"));
40  p.push_back(Parameter::Switch("root", 'r', "Run as fake root"));
41  p.push_back(Parameter::Switch("keep-session", 'k',
42  "Do not remove the session directory when the shell exits"));
43  p.push_back(Parameter::Switch("keep-logs", 'l',
44  "Clean the session directory on shell exit except for the logs"));
45  return p;
46  }
47  virtual unsigned GetMinPlainArgs() const { return 1; }
48 
49  virtual int Main(const Options &options);
50 
51  private:
52  void MountOverlayfs();
53  void CreateUnderlay(const std::string &source_dir,
54  const std::string &dest_dir,
55  const std::vector<std::string> &empty_dirs,
56  std::vector<std::string> *new_paths);
57  void WriteCvmfsConfig(const std::string &extra_config);
58  void MountCvmfs();
59  pid_t RunInteractiveShell();
60 
61  std::string GetCvmfsXattr(const std::string &name);
62  void CleanupSession(bool keep_logs,
63  const std::vector<std::string> &new_paths);
64 
66  std::string fqrn_;
67  std::string cvmfs2_binary_;
68  std::string overlayfs_binary_;
69  std::string session_dir_;
70  std::string env_conf_;
71  std::string rootfs_dir_;
72  std::string stdout_path_;
73  std::string stderr_path_;
74 };
75 
76 } // namespace publish
77 
78 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
std::string session_dir_
In $HOME/.cvmfs/fqrn, container spool area.
Definition: cmd_enter.h:69
std::string stderr_path_
Logs stdout of background commands.
Definition: cmd_enter.h:73
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:32
SettingsSpoolArea settings_spool_area_
Definition: cmd_enter.h:65
virtual int Main(const Options &options)
Definition: cmd_enter.cc:463
std::string cvmfs2_binary_
Definition: cmd_enter.h:67
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:68
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:71
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:70
virtual unsigned GetMinPlainArgs() const
Definition: cmd_enter.h:47
std::string fqrn_
Definition: cmd_enter.h:66
void MountOverlayfs()
Definition: cmd_enter.cc:342
std::string stdout_path_
Logs stdout of background commands.
Definition: cmd_enter.h:72
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