utils: use returncode from subprocess in ogChangeRepo()

... the exception shows the samba password in the logs

specify the error which tells us what has happened according to man mount(8)
Return Codes.
master
OpenGnSys Support Team 2024-02-21 11:15:31 +01:00
parent 92ef3d68aa
commit 8ff6341b69
1 changed files with 3 additions and 4 deletions

View File

@ -194,11 +194,10 @@ def ogChangeRepo(ip, smb_user='opengnsys', smb_pass='og'):
err = 0
cmd = f'mount.cifs -o {mode},username={smb_user},password={smb_pass} {new_name} /opt/opengnsys/images'
try:
result = subprocess.run(shlex.split(cmd), check=True)
except:
result = subprocess.run(shlex.split(cmd))
if result.returncode != 0:
err = -1
logging.error(f'Error mounting {new_name} in /opt/opengnsys/images')
logging.error(f'Error mounting {new_name} in /opt/opengnsys/images with error {result.returncode}')
cmd = f'mount.cifs -o {mode},username={smb_user},password={smb_pass} {orig_name} /opt/opengnsys/images'
subprocess.run(shlex.split(cmd))