Software /
code /
prosody
Comparison
prosodyctl @ 5303:19a4a3462574
Merge 0.9->trunk
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 22 Jan 2013 08:30:38 +0500 |
parent | 5160:da7fe5de82fb |
parent | 5296:78b7a4ad2f32 |
child | 5394:3d1de30fefec |
comparison
equal
deleted
inserted
replaced
5285:19381ed1cc02 | 5303:19a4a3462574 |
---|---|
59 os.exit(1); | 59 os.exit(1); |
60 end | 60 end |
61 | 61 |
62 config = require "core.configmanager" | 62 config = require "core.configmanager" |
63 | 63 |
64 local ENV_CONFIG; | |
64 do | 65 do |
65 local filenames = {}; | 66 local filenames = {}; |
66 | 67 |
67 local filename; | 68 local filename; |
68 if arg[1] == "--config" and arg[2] then | 69 if arg[1] == "--config" and arg[2] then |
69 table.insert(filenames, arg[2]); | 70 table.insert(filenames, arg[2]); |
70 table.remove(arg, 1); table.remove(arg, 1); | |
71 if CFG_CONFIGDIR then | 71 if CFG_CONFIGDIR then |
72 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); | 72 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); |
73 end | 73 end |
74 table.remove(arg, 1); table.remove(arg, 1); | |
74 else | 75 else |
75 for _, format in ipairs(config.parsers()) do | 76 for _, format in ipairs(config.parsers()) do |
76 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format); | 77 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format); |
77 end | 78 end |
78 end | 79 end |
79 for _,_filename in ipairs(filenames) do | 80 for _,_filename in ipairs(filenames) do |
80 filename = _filename; | 81 filename = _filename; |
81 local file = io.open(filename); | 82 local file = io.open(filename); |
82 if file then | 83 if file then |
83 file:close(); | 84 file:close(); |
85 ENV_CONFIG = filename; | |
84 CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); | 86 CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); |
85 break; | 87 break; |
86 end | 88 end |
87 end | 89 end |
88 local ok, level, err = config.load(filename); | 90 local ok, level, err = config.load(filename); |
160 end | 162 end |
161 | 163 |
162 -- Set our umask to protect data files | 164 -- Set our umask to protect data files |
163 pposix.umask(config.get("*", "core", "umask") or "027"); | 165 pposix.umask(config.get("*", "core", "umask") or "027"); |
164 pposix.setenv("HOME", data_path); | 166 pposix.setenv("HOME", data_path); |
167 pposix.setenv("PROSODY_CONFIG", ENV_CONFIG); | |
165 else | 168 else |
166 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") | 169 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") |
167 print("For more help send the below error to us through http://prosody.im/discuss"); | 170 print("For more help send the below error to us through http://prosody.im/discuss"); |
168 print(tostring(pposix)) | 171 print(tostring(pposix)) |
169 os.exit(1); | 172 os.exit(1); |
637 | 640 |
638 show_message(error_messages[msg]) | 641 show_message(error_messages[msg]) |
639 return 1; | 642 return 1; |
640 end | 643 end |
641 | 644 |
642 local openssl = require "util.openssl"; | 645 local openssl; |
643 local lfs = require "lfs"; | 646 local lfs; |
644 | 647 |
645 local cert_commands = {}; | 648 local cert_commands = {}; |
646 | 649 |
647 local function ask_overwrite(filename) | 650 local function ask_overwrite(filename) |
648 return lfs.attributes(filename) and not show_yesno("Overwrite "..filename .. "?"); | 651 return lfs.attributes(filename) and not show_yesno("Overwrite "..filename .. "?"); |
721 end | 724 end |
722 end | 725 end |
723 | 726 |
724 function cert_commands.generate(arg) | 727 function cert_commands.generate(arg) |
725 if #arg >= 1 and arg[1] ~= "--help" then | 728 if #arg >= 1 and arg[1] ~= "--help" then |
726 local cert_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".cert"; | 729 local cert_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".crt"; |
727 if ask_overwrite(cert_filename) then | 730 if ask_overwrite(cert_filename) then |
728 return nil, cert_filename; | 731 return nil, cert_filename; |
729 end | 732 end |
730 local _, key_filename = cert_commands.key({arg[1]}); | 733 local _, key_filename = cert_commands.key({arg[1]}); |
731 local _, conf_filename = cert_commands.config(arg); | 734 local _, conf_filename = cert_commands.config(arg); |
742 end | 745 end |
743 end | 746 end |
744 | 747 |
745 function commands.cert(arg) | 748 function commands.cert(arg) |
746 if #arg >= 1 and arg[1] ~= "--help" then | 749 if #arg >= 1 and arg[1] ~= "--help" then |
750 openssl = require "util.openssl"; | |
751 lfs = require "lfs"; | |
747 local subcmd = table.remove(arg, 1); | 752 local subcmd = table.remove(arg, 1); |
748 if type(cert_commands[subcmd]) == "function" then | 753 if type(cert_commands[subcmd]) == "function" then |
749 if not arg[1] then | 754 if not arg[1] then |
750 show_message"You need to supply at least one hostname" | 755 show_message"You need to supply at least one hostname" |
751 arg = { "--help" }; | 756 arg = { "--help" }; |