From eed4a649bf9307459029941f9429036f1b80b58c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Wed, 23 Jan 2019 18:14:02 +0100
Subject: [PATCH] fix updating of the configuration file, refs #26945

---
 5.MediaServer/3.Deploy_demokit/0_setup.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/5.MediaServer/3.Deploy_demokit/0_setup.py b/5.MediaServer/3.Deploy_demokit/0_setup.py
index 3a7f5e14..a8ea900a 100644
--- a/5.MediaServer/3.Deploy_demokit/0_setup.py
+++ b/5.MediaServer/3.Deploy_demokit/0_setup.py
@@ -22,23 +22,23 @@ def setup(interactive=True):
         cmd = cmd_template % c
         cmds.append(cmd)
 
-    with open('/etc/miris/netcapture.json', 'r+') as f:
+    with open('/etc/miris/netcapture.json', 'r') as f:
         c = json.load(f)
-        c['campusmanager_check_ssl'] = False
-        json.dump(c, f)
-
-    cmds.append('rsync -r mirisconf/ /etc/miris/conf')
-    cmds.append('netcapturectl add')
+    c['campusmanager_check_ssl'] = False
 
     # try to enable hw accel if available
     subprocess.getstatusoutput("apt install -y vainfo")
     if subprocess.getstatusoutput("vainfo")[0] == 0:
         # hw acceleration requires boot-time module options so a reboot will be needed
-        with open('/etc/miris/netcapture.json', 'r+') as f:
-            c = json.load(f)
-            c['enable_hw_acceleration'] = True
-            json.dump(c, f)
+        c['enable_hw_acceleration'] = True
         cmds.append('echo "options i915 enable_guc_loading=1 enable_guc_submission=1" > /etc/modprobe.d/netcapture.conf')
         cmds.append('update-initramfs -u')
         print('A reboot is required')
+
+    with open('/etc/miris/netcapture.json', 'w') as f:
+        json.dump(c, f)
+
+    cmds.append('rsync -r mirisconf/ /etc/miris/conf')
+    cmds.append('netcapturectl add')
+
     utils.run_commands(cmds)
-- 
GitLab