aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-07-09 01:09:57 +0100
committerMatthew Wild <mwild1@gmail.com>2010-07-09 01:09:57 +0100
commited0cef77181841ce3063dccbb79f13ee85a14cae (patch)
tree5e00d29dead2db03308bd46a3ff036acdad68c6f /prosodyctl
parent9dfb2ebfb460edd3fdf98f368176c14140801644 (diff)
downloadprosody-ed0cef77181841ce3063dccbb79f13ee85a14cae.tar.gz
prosody-ed0cef77181841ce3063dccbb79f13ee85a14cae.zip
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl41
1 files changed, 40 insertions, 1 deletions
diff --git a/prosodyctl b/prosodyctl
index b2cb43f4..9bb8d4ad 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -64,7 +64,7 @@ do
os.exit(1);
end
end
-
+local original_logging_config = config.get("*", "core", "log");
config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } });
require "core.loggingmanager"
@@ -111,6 +111,45 @@ else
print(tostring(pposix))
end
+local function test_writeable(filename)
+ local f, err = io.open(filename, "a");
+ if not f then
+ return false, err;
+ end
+ f:close();
+ return true;
+end
+
+local unwriteable_files = {};
+if type(original_logging_config) == "string" and original_logging_config:sub(1,1) ~= "*" then
+ local ok, err = test_writeable(original_logging_config);
+ if not ok then
+ table.insert(unwriteable_files, err);
+ end
+elseif type(original_logging_config) == "table" then
+ for _, rule in ipairs(original_logging_config) do
+ if rule.filename then
+ local ok, err = test_writeable(rule.filename);
+ if not ok then
+ table.insert(unwriteable_files, err);
+ end
+ end
+ end
+end
+
+if #unwriteable_files > 0 then
+ print("One of more of the Prosody log files are not");
+ print("writeable, please correct the errors and try");
+ print("starting prosodyctl again.");
+ print("");
+ for _, err in ipairs(unwriteable_files) do
+ print(err);
+ end
+ print("");
+ os.exit(1);
+end
+
+
local error_messages = setmetatable({
["invalid-username"] = "The given username is invalid in a Jabber ID";
["invalid-hostname"] = "The given hostname is invalid";