Add global variable to set up OpenGnsys path

This variable allow us to modify the opengnsys path without modify several parts
of the code. This change reduces the probability to add any bug forgetting to
change any line.
more_events
Alvaro Neira Ayuso 2019-12-16 10:18:12 +01:00 committed by Alvaro Neira Ayuso
parent 694bc492a2
commit 2997952bc9
1 changed files with 4 additions and 2 deletions

View File

@ -1,14 +1,16 @@
import os
import subprocess
OG_PATH = '/opt/opengnsys/'
def poweroff():
if os.path.exists('/scripts/oginit'):
subprocess.call('source /opt/opengnsys/etc/preinit/loadenviron.sh; /opt/opengnsys/scripts/poweroff', shell=True)
subprocess.call('source ' + OG_SCRIPT_PATH + 'etc/preinit/loadenviron.sh; ' + OG_SCRIPT_PATH + 'scripts/poweroff', shell=True)
else:
subprocess.call(['/sbin/poweroff'])
def reboot():
if os.path.exists('/scripts/oginit'):
subprocess.call('source /opt/opengnsys/etc/preinit/loadenviron.sh; /opt/opengnsys/scripts/reboot', shell=True)
subprocess.call('source ' + OG_SCRIPT_PATH + 'etc/preinit/loadenviron.sh; ' + OG_SCRIPT_PATH + 'scripts/reboot', shell=True)
else:
subprocess.call(['/sbin/reboot'])