This commit is contained in:
@@ -296,6 +296,12 @@
|
||||
|
||||
bool template_manager::test_template(const std::string &template_path)
|
||||
{
|
||||
if (template_path.empty())
|
||||
return false;
|
||||
|
||||
if (!std::filesystem::exists(template_path))
|
||||
return false;
|
||||
|
||||
std::string template_name = std::filesystem::path(template_path).filename().string();
|
||||
|
||||
std::vector<std::string> required_files = {
|
||||
@@ -303,13 +309,22 @@
|
||||
"config/.template_info.env",
|
||||
"_default.env",
|
||||
"install.sh",
|
||||
"uninstall.sh",
|
||||
"nuke.sh"
|
||||
"uninstall.sh"
|
||||
};
|
||||
|
||||
for (const auto& file : required_files) {
|
||||
if (!required_file(template_path + "/" + file, template_name))
|
||||
return false;
|
||||
|
||||
// check if file is executable, if it ends in .sh
|
||||
std::string suffix=".sh";
|
||||
if (file.find(suffix) == file.size() - suffix.size())
|
||||
{
|
||||
std::filesystem::path path = template_path + "/" + file;
|
||||
auto perms = std::filesystem::status(path).permissions();
|
||||
if ((perms & std::filesystem::perms::owner_exec) == std::filesystem::perms::none)
|
||||
std::cerr << "Error: " << file << " is not executable" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
@@ -356,4 +371,13 @@
|
||||
return instance;
|
||||
}
|
||||
|
||||
template_info::template_info(const std::string &template_name, const std::string &location_id, const std::filesystem::path &local_template_path) :
|
||||
mTemplateName(template_name),
|
||||
mLocationID(location_id),
|
||||
mTemplateLocalPath(local_template_path),
|
||||
mTemplateValid(template_manager::test_template(local_template_path.string())),
|
||||
mIsSet(!template_name.empty() && !location_id.empty() && !local_template_path.empty())
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
||||
|
Reference in New Issue
Block a user