controlscript must be located in plugin_dir

This commit is contained in:
badaix 2025-01-21 22:25:04 +01:00
parent be266c07ce
commit 8e9806f35c
13 changed files with 137 additions and 46 deletions

View file

@ -129,15 +129,15 @@ void StreamControl::onLog(std::string message)
ScriptStreamControl::ScriptStreamControl(const boost::asio::any_io_executor& executor, const std::string& script, const std::string& params)
: StreamControl(executor), script_(script), params_(params)
ScriptStreamControl::ScriptStreamControl(const boost::asio::any_io_executor& executor, const std::filesystem::path& plugin_dir, std::string script,
std::string params)
: StreamControl(executor), script_(std::move(script)), params_(std::move(params))
{
namespace fs = utils::file;
if (!fs::exists(script_))
{
std::string plugin_path = "/usr/share/snapserver/plug-ins/";
if (fs::exists(plugin_path + script_))
script_ = plugin_path + script_;
if (fs::exists(plugin_dir / script_))
script_ = plugin_dir / script_;
else
throw SnapException("Control script not found: \"" + script_ + "\"");
}