From 9c10d7a28e8fba59df9da78747c992e4fa944c9d Mon Sep 17 00:00:00 2001 From: lejeune quentin Date: Tue, 10 Sep 2019 13:06:45 +0000 Subject: [PATCH] [FIX] hw_drivers: Fix unmount of cups folder To add or modify printer the /root_bypass_ramdisks/etc/cups/ need be writeable. And /root_bypass_ramdisks/etc/cups/ = /etc/cups/ But when we make 'sudo mount -o remount,ro /' we put the /etc/cups/ and so /root_bypass_ramdisks/etc/cups/ folder on read-only. After all 'read-only' command we make another command to put cups folder writeable --- addons/hw_drivers/tools/helpers.py | 4 ++++ addons/hw_posbox_homepage/controllers/main.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hw_drivers/tools/helpers.py b/addons/hw_drivers/tools/helpers.py index 9cc25440304..9a1b5e2064a 100644 --- a/addons/hw_drivers/tools/helpers.py +++ b/addons/hw_drivers/tools/helpers.py @@ -109,6 +109,7 @@ def load_certificate(): Path('/root_bypass_ramdisks/etc/ssl/private/nginx-cert.key').write_text(result['private_key_pem']) subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/root_bypass_ramdisks/"]) + subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/root_bypass_ramdisks/etc/cups"]) subprocess.check_call(["sudo", "service", "nginx", "restart"]) def download_drivers(auto=True): @@ -127,6 +128,7 @@ def download_drivers(auto=True): zip_file = zipfile.ZipFile(io.BytesIO(resp.data)) zip_file.extractall(get_resource_path('hw_drivers', 'drivers')) subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) + subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/root_bypass_ramdisks/etc/cups"]) except Exception as e: _logger.error('Could not reach configured server') _logger.error('A error encountered : %s ' % e) @@ -145,9 +147,11 @@ def unlink_file(filename): if path.exists(): path.unlink() subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) + subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/root_bypass_ramdisks/etc/cups"]) def write_file(filename, text): subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"]) path = Path.home() / filename path.write_text(text) subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) + subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/root_bypass_ramdisks/etc/cups"]) diff --git a/addons/hw_posbox_homepage/controllers/main.py b/addons/hw_posbox_homepage/controllers/main.py index 0bfd7d06b28..e9344ae616e 100644 --- a/addons/hw_posbox_homepage/controllers/main.py +++ b/addons/hw_posbox_homepage/controllers/main.py @@ -140,11 +140,9 @@ class IoTboxHomepage(web.Home): @http.route('/clear_credential', type='http', auth='none', cors='*', csrf=False) def clear_credential(self): - subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"]) helpers.unlink_file('odoo-db-uuid.conf') helpers.unlink_file('odoo-enterprise-code.conf') subprocess.check_call(["sudo", "service", "odoo", "restart"]) - subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) return "" def get_wifi_essid(self):