mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Set service to manual if disabled on start
This commit is contained in:
parent
c30656814d
commit
1e1ee786c9
1 changed files with 17 additions and 1 deletions
|
@ -157,7 +157,18 @@ def get_service_name(*args):
|
|||
|
||||
def start(name):
|
||||
'''
|
||||
Start the specified service
|
||||
Start the specified service.
|
||||
|
||||
.. warning::
|
||||
You cannot start a disabled service in Windows. If the service is
|
||||
disabled, it will be changed to ``Manual`` start.
|
||||
|
||||
Args:
|
||||
|
||||
name (str): The name of the service to start
|
||||
|
||||
Returns:
|
||||
bool: True if successful, otherwise False
|
||||
|
||||
CLI Example:
|
||||
|
||||
|
@ -165,6 +176,11 @@ def start(name):
|
|||
|
||||
salt '*' service.start <service name>
|
||||
'''
|
||||
# Set the service to manual if disabled
|
||||
if disabled(name):
|
||||
cmd = ['sc', 'config', name, 'start=demand']
|
||||
__salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
cmd = ['net', 'start', '/y', name]
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue