CernVM-FS  2.10.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  p.push_back(Parameter::Switch("transaction", 't',
46  "Open a transaction within the ephemeral shell"));
47  p.push_back(
48  Parameter::Optional("repo-config", 'x', "repository configuration",
49  "Path to the configuration of the repository as in "
50  "/etc/cvmfs/repositories.d"));
51  return p;
52  }
53  virtual unsigned GetMinPlainArgs() const { return 1; }
54 
55  virtual int Main(const Options &options);
56 
57  private:
58  void MountOverlayfs();
59  void CreateUnderlay(const std::string &source_dir,
60  const std::string &dest_dir,
61  const std::vector<std::string> &empty_dirs,
62  std::vector<std::string> *new_paths);
63  void WriteCvmfsConfig(const std::string &extra_config);
64  void MountCvmfs();
65  pid_t RunInteractiveShell();
66 
67  std::string GetCvmfsXattr(const std::string &name);
68  void CleanupSession(bool keep_logs,
69  const std::vector<std::string> &new_paths);
70 
72  std::string fqrn_;
73  std::string cvmfs2_binary_;
74  std::string repo_config_;
75  std::string overlayfs_binary_;
76  std::string session_dir_;
77  std::string env_conf_;
78  std::string rootfs_dir_;
79  std::string stdout_path_;
80  std::string stderr_path_;
81 };
82 
83 } // namespace publish
84 
85 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
std::string session_dir_
In $HOME/.cvmfs/fqrn, container spool area.
Definition: cmd_enter.h:76
std::string stderr_path_
Logs stdout of background commands.
Definition: cmd_enter.h:80
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:71
virtual int Main(const Options &options)
Definition: cmd_enter.cc:469
std::string cvmfs2_binary_
Definition: cmd_enter.h:73
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:75
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:78
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:77
virtual unsigned GetMinPlainArgs() const
Definition: cmd_enter.h:53
std::string fqrn_
Definition: cmd_enter.h:72
void MountOverlayfs()
Definition: cmd_enter.cc:342
std::string stdout_path_
Logs stdout of background commands.
Definition: cmd_enter.h:79
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:74