prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Action 'linux.service' fails on Centos7
  When I tried to execute restart some service on the Centos7 server got the following error:
  ```
  Traceback (most recent call last):
    File "/tmp/5a0459bc07ac686fb813a920/service.py", line 24, in <module>
      subprocess.call(cmd, shell=True)
  NameError: name 'cmd' is not defined
  ```
  After investigation the resolution has been found:
  in file /opt/stackstorm/packs/linux/actions/service.py the entry
  
  `elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):`
  
  fixed to 
  
  `elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora') or re.search(distro, 'CentOS Linux'):`
  
  The issue has gone
  
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `contrib/linux/actions/service.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 
  3 import re
  4 import sys
  5 import os
  6 import platform
  7 import subprocess
  8 
  9 distro = platform.linux_distribution()[0]
  10 
  11 args = {'act': sys.argv[1], 'service': sys.argv[2]}
  12 
  13 if re.search(distro, 'Ubuntu'):
  14     if os.path.isfile("/etc/init/%s.conf" % args['service']):
  15         cmd = args['act'] + " " + args['service']
  16     elif os.path.isfile("/etc/init.d/%s" % args['service']):
  17         cmd = "/etc/init.d/%s %s" % (args['service'], args['act'])
  18     else:
  19         print("Unknown service")
  20         sys.exit(2)
  21 elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):
  22     cmd = "systemctl %s %s" % (args['act'], args['service'])
  23 
  24 subprocess.call(cmd, shell=True)
  25
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/contrib/linux/actions/service.py b/contrib/linux/actions/service.py
  --- a/contrib/linux/actions/service.py
  +++ b/contrib/linux/actions/service.py
  @@ -18,7 +18,8 @@
       else:
           print("Unknown service")
           sys.exit(2)
  -elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):
  +elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora') or \
  +        re.search(distro, 'CentOS Linux'):
       cmd = "systemctl %s %s" % (args['act'], args['service'])
   
   subprocess.call(cmd, shell=True)
  
verification_info: {"golden_diff": "diff --git a/contrib/linux/actions/service.py b/contrib/linux/actions/service.py\n--- a/contrib/linux/actions/service.py\n+++ b/contrib/linux/actions/service.py\n@@ -18,7 +18,8 @@\n     else:\n         print(\"Unknown service\")\n         sys.exit(2)\n-elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):\n+elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora') or \\\n+        re.search(distro, 'CentOS Linux'):\n     cmd = \"systemctl %s %s\" % (args['act'], args['service'])\n \n subprocess.call(cmd, shell=True)\n", "issue": "Action 'linux.service' fails on Centos7\nWhen I tried to execute restart some service on the Centos7 server got the following error:\r\n```\r\nTraceback (most recent call last):\r\n  File \"/tmp/5a0459bc07ac686fb813a920/service.py\", line 24, in <module>\r\n    subprocess.call(cmd, shell=True)\r\nNameError: name 'cmd' is not defined\r\n```\r\nAfter investigation the resolution has been found:\r\nin file /opt/stackstorm/packs/linux/actions/service.py the entry\r\n\r\n`elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):`\r\n\r\nfixed to \r\n\r\n`elif re.search(distro, 'Redhat') or re.search(distro, 'Fedora') or re.search(distro, 'CentOS Linux'):`\r\n\r\nThe issue has gone\r\n\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\nimport re\nimport sys\nimport os\nimport platform\nimport subprocess\n\ndistro = platform.linux_distribution()[0]\n\nargs = {'act': sys.argv[1], 'service': sys.argv[2]}\n\nif re.search(distro, 'Ubuntu'):\n    if os.path.isfile(\"/etc/init/%s.conf\" % args['service']):\n        cmd = args['act'] + \" \" + args['service']\n    elif os.path.isfile(\"/etc/init.d/%s\" % args['service']):\n        cmd = \"/etc/init.d/%s %s\" % (args['service'], args['act'])\n    else:\n        print(\"Unknown service\")\n        sys.exit(2)\nelif re.search(distro, 'Redhat') or re.search(distro, 'Fedora'):\n    cmd = \"systemctl %s %s\" % (args['act'], args['service'])\n\nsubprocess.call(cmd, shell=True)\n", "path": "contrib/linux/actions/service.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nimport re\nimport sys\nimport os\nimport platform\nimport subprocess\n\ndistro = platform.linux_distribution()[0]\n\nargs = {'act': sys.argv[1], 'service': sys.argv[2]}\n\nif re.search(distro, 'Ubuntu'):\n    if os.path.isfile(\"/etc/init/%s.conf\" % args['service']):\n        cmd = args['act'] + \" \" + args['service']\n    elif os.path.isfile(\"/etc/init.d/%s\" % args['service']):\n        cmd = \"/etc/init.d/%s %s\" % (args['service'], args['act'])\n    else:\n        print(\"Unknown service\")\n        sys.exit(2)\nelif re.search(distro, 'Redhat') or re.search(distro, 'Fedora') or \\\n        re.search(distro, 'CentOS Linux'):\n    cmd = \"systemctl %s %s\" % (args['act'], args['service'])\n\nsubprocess.call(cmd, shell=True)\n", "path": "contrib/linux/actions/service.py"}]}