prosodyctl
changeset 12107 fc297128c33a
parent 12106 949c2b52f51e
child 12268 ba712f7559dc
equal deleted inserted replaced
12106:949c2b52f51e 12107:fc297128c33a
   224 
   224 
   225 	show_message(error_messages[msg])
   225 	show_message(error_messages[msg])
   226 	return 1;
   226 	return 1;
   227 end
   227 end
   228 
   228 
       
   229 local function has_init_system() --> which
       
   230 	lfs = lfs or require"lfs";
       
   231 	if lfs.attributes("/etc/systemd") then
       
   232 		return "systemd";
       
   233 	elseif lfs.attributes("/etc/init.d/prosody") then
       
   234 		return "rc.d";
       
   235 	end
       
   236 end
       
   237 
   229 local function service_command_warning(service_command)
   238 local function service_command_warning(service_command)
   230 	if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then
   239 	if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then
   231 		show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended");
   240 		show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended");
   232 		show_warning("         if Prosody is managed by an init system - use that directly instead.");
   241 		show_warning("         if Prosody is managed by an init system - use that directly instead.");
   233 		lfs = lfs or require"lfs";
   242 		local init = has_init_system()
   234 		if lfs.attributes("/etc/systemd") then
   243 		if init == "systemd" then
   235 			show_warning("         e.g. systemctl %s prosody", service_command);
   244 			show_warning("         e.g. systemctl %s prosody", service_command);
   236 		elseif lfs.attributes("/etc/init.d/prosody") then
   245 		elseif init == "rc.d" then
   237 			show_warning("         e.g. /etc/init.d/prosody %s", service_command);
   246 			show_warning("         e.g. /etc/init.d/prosody %s", service_command);
   238 		end
   247 		end
   239 		show_warning("");
   248 		show_warning("");
   240 	end
   249 	end
   241 end
   250 end
   674 			shell = "Interact with a running Prosody",
   683 			shell = "Interact with a running Prosody",
   675 		}
   684 		}
   676 
   685 
   677 		local done = {};
   686 		local done = {};
   678 
   687 
       
   688 		if prosody.installed and has_init_system() then
       
   689 			-- Hide start, stop, restart
       
   690 			done[table.remove(commands_order, 2)] = true;
       
   691 			done[table.remove(commands_order, 2)] = true;
       
   692 			done[table.remove(commands_order, 2)] = true;
       
   693 		end
       
   694 
   679 		for _, command_name in ipairs(commands_order) do
   695 		for _, command_name in ipairs(commands_order) do
   680 			local command_func = commands[command_name];
   696 			local command_func = commands[command_name];
   681 			if command_func then
   697 			if command_func then
   682 				command_func{ "--help" };
   698 				command_func{ "--help" };
   683 				done[command_name] = true;
   699 				done[command_name] = true;