Software / code / prosody
Comparison
prosodyctl @ 5394:3d1de30fefec
Merge 0.9->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 28 Mar 2013 12:17:15 +0000 |
| parent | 5303:19a4a3462574 |
| parent | 5384:24f4aed5824f |
| child | 5442:e66973c81e89 |
comparison
equal
deleted
inserted
replaced
| 5382:214c32e10734 | 5394:3d1de30fefec |
|---|---|
| 107 print("**************************"); | 107 print("**************************"); |
| 108 print(""); | 108 print(""); |
| 109 os.exit(1); | 109 os.exit(1); |
| 110 end | 110 end |
| 111 end | 111 end |
| 112 local original_logging_config = config.get("*", "core", "log"); | 112 local original_logging_config = config.get("*", "log"); |
| 113 config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); | 113 config.set("*", "log", { { levels = { min="info" }, to = "console" } }); |
| 114 | 114 |
| 115 local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; | 115 local data_path = config.get("*", "data_path") or CFG_DATADIR or "data"; |
| 116 local custom_plugin_paths = config.get("*", "core", "plugin_paths"); | 116 local custom_plugin_paths = config.get("*", "plugin_paths"); |
| 117 if custom_plugin_paths then | 117 if custom_plugin_paths then |
| 118 local path_sep = package.config:sub(3,3); | 118 local path_sep = package.config:sub(3,3); |
| 119 -- path1;path2;path3;defaultpath... | 119 -- path1;path2;path3;defaultpath... |
| 120 CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); | 120 CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); |
| 121 end | 121 end |
| 140 if ok and pposix then | 140 if ok and pposix then |
| 141 if pposix._VERSION ~= want_pposix_version then print(string.format("Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version)); return; end | 141 if pposix._VERSION ~= want_pposix_version then print(string.format("Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version)); return; end |
| 142 current_uid = pposix.getuid(); | 142 current_uid = pposix.getuid(); |
| 143 if current_uid == 0 then | 143 if current_uid == 0 then |
| 144 -- We haz root! | 144 -- We haz root! |
| 145 local desired_user = config.get("*", "core", "prosody_user") or "prosody"; | 145 local desired_user = config.get("*", "prosody_user") or "prosody"; |
| 146 local desired_group = config.get("*", "core", "prosody_group") or desired_user; | 146 local desired_group = config.get("*", "prosody_group") or desired_user; |
| 147 local ok, err = pposix.setgid(desired_group); | 147 local ok, err = pposix.setgid(desired_group); |
| 148 if ok then | 148 if ok then |
| 149 ok, err = pposix.initgroups(desired_user); | 149 ok, err = pposix.initgroups(desired_user); |
| 150 end | 150 end |
| 151 if ok then | 151 if ok then |
| 160 print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err)); | 160 print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err)); |
| 161 end | 161 end |
| 162 end | 162 end |
| 163 | 163 |
| 164 -- Set our umask to protect data files | 164 -- Set our umask to protect data files |
| 165 pposix.umask(config.get("*", "core", "umask") or "027"); | 165 pposix.umask(config.get("*", "umask") or "027"); |
| 166 pposix.setenv("HOME", data_path); | 166 pposix.setenv("HOME", data_path); |
| 167 pposix.setenv("PROSODY_CONFIG", ENV_CONFIG); | 167 pposix.setenv("PROSODY_CONFIG", ENV_CONFIG); |
| 168 else | 168 else |
| 169 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.") |
| 170 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"); |
| 265 local getchar, getpass = prosodyctl.getchar, prosodyctl.getpass; | 265 local getchar, getpass = prosodyctl.getchar, prosodyctl.getpass; |
| 266 local show_yesno = prosodyctl.show_yesno; | 266 local show_yesno = prosodyctl.show_yesno; |
| 267 local show_prompt = prosodyctl.show_prompt; | 267 local show_prompt = prosodyctl.show_prompt; |
| 268 local read_password = prosodyctl.read_password; | 268 local read_password = prosodyctl.read_password; |
| 269 | 269 |
| 270 local prosodyctl_timeout = (config.get("*", "core", "prosodyctl_timeout") or 5) * 2; | 270 local prosodyctl_timeout = (config.get("*", "prosodyctl_timeout") or 5) * 2; |
| 271 ----------------------- | 271 ----------------------- |
| 272 local commands = {}; | 272 local commands = {}; |
| 273 local command = arg[1]; | 273 local command = arg[1]; |
| 274 | 274 |
| 275 function commands.adduser(arg) | 275 function commands.adduser(arg) |
| 408 return 1; | 408 return 1; |
| 409 end | 409 end |
| 410 | 410 |
| 411 local ok, ret = prosodyctl.start(); | 411 local ok, ret = prosodyctl.start(); |
| 412 if ok then | 412 if ok then |
| 413 if config.get("*", "core", "daemonize") ~= false then | 413 if config.get("*", "daemonize") ~= false then |
| 414 local i=1; | 414 local i=1; |
| 415 while true do | 415 while true do |
| 416 local ok, running = prosodyctl.isrunning(); | 416 local ok, running = prosodyctl.isrunning(); |
| 417 if ok and running then | 417 if ok and running then |
| 418 break; | 418 break; |