29 std::string lease_path;
34 if (tokens.size() == 2)
50 if (settings->transaction().in_enter_session()) {
51 throw EPublish(
"opening a transaction is unsupported within the ephemeral "
55 if (options.
Has(
"retry-timeout")) {
56 settings->GetTransaction()->SetTimeout(options.
GetInt(
"retry-timeout"));
58 if (options.
Has(
"template-from")) {
59 if (!options.
Has(
"template-to"))
60 throw EPublish(
"invalid parameter combination for templates");
61 settings->GetTransaction()->SetTemplate(options.
GetString(
"template-from"),
64 if (options.
Has(
"template")) {
65 if (options.
Has(
"template-from") || options.
Has(
"template-to"))
66 throw EPublish(
"invalid parameter combination for templates");
67 std::string templ = options.
GetString(
"template");
68 std::vector<std::string> tokens =
SplitString(templ,
'=');
69 if (tokens.size() != 2)
70 throw EPublish(
"invalid syntax for --template parameter: " + templ);
71 settings->GetTransaction()->SetTemplate(tokens[0], tokens[1]);
76 throw EPublish(
"No write permission to repository",
81 throw EPublish(
"Autofs on /cvmfs has to be disabled");
83 settings->GetTransaction()->SetLeasePath(lease_path);
89 if (publisher->whitelist()->IsExpired()) {
90 throw EPublish(
"Repository whitelist for $name is expired",
102 double whitelist_valid_s = difftime(publisher->whitelist()->expires(),
104 if (whitelist_valid_s < (12 * 60 * 60)) {
107 "Warning: Repository whitelist stays valid for less than 12 hours!");
113 "transaction hook failed, not opening a transaction");
118 publisher->Transaction();
120 const char *msg_prefix =
"CernVM-FS transaction error: ";
145 publisher->session()->SetKeepAlive(
true);
150 "post transaction hook failed");
int GetInt(const std::string &key) const
SettingsPublisher * CreateSettingsPublisher(const std::string &ident, bool needs_managed=false)
int CallServerHook(const std::string &func, const std::string &fqrn, const std::string &path_hooks="/etc/cvmfs/cvmfs_server_hooks.sh")
bool Has(const std::string &key) const
std::string GetString(const std::string &key) const
const SettingsPublisher & settings() const
const std::vector< Argument > & plain_args() const
vector< string > SplitString(const string &str, char delim)
FileSystemInfo GetFileSystemInfo(const std::string &path)
virtual int Main(const Options &options)
vector< string > SplitStringBounded(unsigned max_chunks, const string &str, char delim)
EFailures failure() const
bool SwitchCredentials(const uid_t uid, const gid_t gid, const bool temporarily)
Publisher(const SettingsPublisher &settings, const bool exists=true)
std::string MakeCanonicalPath(const std::string &path)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)