--- Try to determine version
-local version_file = io.open((CFG_SOURCEDIR or ".").."/prosody.version");
-if version_file then
- prosody.version = version_file:read("*a"):gsub("%s*$", "");
- version_file:close();
- if #prosody.version == 12 and prosody.version:match("^[a-f0-9]+$") then
- prosody.version = "hg:"..prosody.version;
+ prosody.events = require "util.events".new();
+
+ prosody.platform = "unknown";
+ if os.getenv("WINDIR") then
+ prosody.platform = "windows";
+ elseif package.config:sub(1,1) == "/" then
+ prosody.platform = "posix";
+ end
+
+ prosody.installed = nil;
+ if CFG_SOURCEDIR and (prosody.platform == "windows" or CFG_SOURCEDIR:match("^/")) then
+ prosody.installed = true;
+ end
+
+ -- Function to reload the config file
+ function prosody.reload_config()
+ log("info", "Reloading configuration file");
+ prosody.events.fire_event("reloading-config");
+ local ok, level, err = config.load((rawget(_G, "CFG_CONFIGDIR") or ".").."/prosody.cfg.lua");
+ if not ok then
+ if level == "parser" then
+ log("error", "There was an error parsing the configuration file: %s", tostring(err));
+ elseif level == "file" then
+ log("error", "Couldn't read the config file when trying to reload: %s", tostring(err));
+ end
+ end
+ return ok, (err and tostring(level)..": "..tostring(err)) or nil;