diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-02-07 13:45:11 +0100 |
---|---|---|
committer | Alvaro Neira Ayuso <aneira@soleta.eu> | 2020-02-09 00:04:43 +0100 |
commit | 54c0ebf0983d6144c6cb7597290beb1e8bb39e7b (patch) | |
tree | 185c4a0d917703bbcfccc2336326821f509bcb76 | |
parent | 1fd9f2e07c8a60860faa013699b85507824e4020 (diff) |
Use 'bash' as the default shell for operations scripts
-rw-r--r-- | src/linux/ogOperations.py | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 483e7f2..3989a1c 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -10,6 +10,7 @@ import os import subprocess OG_PATH = '/opt/opengnsys/' +OG_SHELL = '/bin/bash' def parseGetConf(out): parsed = {'serial_number': '', @@ -38,13 +39,17 @@ def parseGetConf(out): def poweroff(): if os.path.exists('/scripts/oginit'): - subprocess.call('source ' + OG_PATH + 'etc/preinit/loadenviron.sh; ' + OG_PATH + 'scripts/poweroff', shell=True) + cmd = f'source {OG_PATH}etc/preinit/loadenviron.sh; ' \ + f'{OG_PATH}scripts/poweroff' + subprocess.call([cmd], shell=True, executable=OG_SHELL) else: subprocess.call(['/sbin/poweroff']) def reboot(): if os.path.exists('/scripts/oginit'): - subprocess.call('source ' + OG_PATH + 'etc/preinit/loadenviron.sh; ' + OG_PATH + 'scripts/reboot', shell=True) + cmd = f'source {OG_PATH}etc/preinit/loadenviron.sh; ' \ + f'{OG_PATH}scripts/reboot' + subprocess.call([cmd], shell=True, executable=OG_SHELL) else: subprocess.call(['/sbin/reboot']) @@ -52,7 +57,10 @@ def execCMD(request, ogRest): cmd = request.getrun() cmds = cmd.split(";|\n") try: - ogRest.proc = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=True) + ogRest.proc = subprocess.Popen(cmds, + stdout=subprocess.PIPE, + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -67,7 +75,8 @@ def session(request, ogRest): try: ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -84,7 +93,8 @@ def software(request, path, ogRest): ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -96,7 +106,8 @@ def hardware(path, ogRest): cmd = f'{OG_PATH}interfaceAdm/InventarioHardware {path}' ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -122,7 +133,8 @@ def setup(request, ogRest): try: ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -144,8 +156,9 @@ def image_restore(request, ogRest): try: ogRest.proc = subprocess.Popen([cmd], - stdout=subprocess.PIPE, - shell=True) + stdout=subprocess.PIPE, + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -165,7 +178,8 @@ def image_create(path, request, ogRest): try: ogRest.proc = subprocess.Popen([cmd_software], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -176,7 +190,8 @@ def image_create(path, request, ogRest): try: ogRest.proc = subprocess.Popen([cmd_create_image], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') @@ -188,7 +203,8 @@ def refresh(ogRest): cmd = f'{OG_PATH}interfaceAdm/getConfiguration' ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, - shell=True) + shell=True, + executable=OG_SHELL) (output, error) = ogRest.proc.communicate() except: raise ValueError('Error: Incorrect command value') |