mirror of https://git.48k.eu/ogclient
Use 'bash' as the default shell for operations scripts
parent
1fd9f2e07c
commit
54c0ebf098
|
@ -10,6 +10,7 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
OG_PATH = '/opt/opengnsys/'
|
OG_PATH = '/opt/opengnsys/'
|
||||||
|
OG_SHELL = '/bin/bash'
|
||||||
|
|
||||||
def parseGetConf(out):
|
def parseGetConf(out):
|
||||||
parsed = {'serial_number': '',
|
parsed = {'serial_number': '',
|
||||||
|
@ -38,13 +39,17 @@ def parseGetConf(out):
|
||||||
|
|
||||||
def poweroff():
|
def poweroff():
|
||||||
if os.path.exists('/scripts/oginit'):
|
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:
|
else:
|
||||||
subprocess.call(['/sbin/poweroff'])
|
subprocess.call(['/sbin/poweroff'])
|
||||||
|
|
||||||
def reboot():
|
def reboot():
|
||||||
if os.path.exists('/scripts/oginit'):
|
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:
|
else:
|
||||||
subprocess.call(['/sbin/reboot'])
|
subprocess.call(['/sbin/reboot'])
|
||||||
|
|
||||||
|
@ -52,7 +57,10 @@ def execCMD(request, ogRest):
|
||||||
cmd = request.getrun()
|
cmd = request.getrun()
|
||||||
cmds = cmd.split(";|\n")
|
cmds = cmd.split(";|\n")
|
||||||
try:
|
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()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -67,7 +75,8 @@ def session(request, ogRest):
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -84,7 +93,8 @@ def software(request, path, ogRest):
|
||||||
|
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -96,7 +106,8 @@ def hardware(path, ogRest):
|
||||||
cmd = f'{OG_PATH}interfaceAdm/InventarioHardware {path}'
|
cmd = f'{OG_PATH}interfaceAdm/InventarioHardware {path}'
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -122,7 +133,8 @@ def setup(request, ogRest):
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -144,8 +156,9 @@ def image_restore(request, ogRest):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -165,7 +178,8 @@ def image_create(path, request, ogRest):
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd_software],
|
ogRest.proc = subprocess.Popen([cmd_software],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -176,7 +190,8 @@ def image_create(path, request, ogRest):
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd_create_image],
|
ogRest.proc = subprocess.Popen([cmd_create_image],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
ogRest.proc.communicate()
|
ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
@ -188,7 +203,8 @@ def refresh(ogRest):
|
||||||
cmd = f'{OG_PATH}interfaceAdm/getConfiguration'
|
cmd = f'{OG_PATH}interfaceAdm/getConfiguration'
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True)
|
shell=True,
|
||||||
|
executable=OG_SHELL)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
raise ValueError('Error: Incorrect command value')
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
|
Loading…
Reference in New Issue