From 89c166b206f933626e0d04de85fc9260e969ad6b Mon Sep 17 00:00:00 2001
From: Nicolas KAROLAK <nicolas@karolak.fr>
Date: Fri, 22 Mar 2019 15:18:13 +0100
Subject: [PATCH] check presence of nscd

---
 set_app_domain.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/set_app_domain.py b/set_app_domain.py
index 1b859d3b..9c89be86 100755
--- a/set_app_domain.py
+++ b/set_app_domain.py
@@ -3,6 +3,7 @@
 '''
 Script to set the domain of an existing MediaServer, Miris Manager or Monitor
 '''
+import apt
 import os
 import re
 import subprocess
@@ -162,7 +163,13 @@ class SetAppDomain():
                 with open('/etc/hosts', 'w') as fo:
                     fo.write(new_hosts)
                 log('The "/etc/hosts" file has been update.')
-                utils.run_commands(['service nscd restart'])
+                cache = apt.Cache()
+                cache.open()
+                try:
+                    cache['nscd'].is_installed
+                    utils.run_commands(['service nscd restart'])
+                except KeyError:
+                    pass
         else:
             log('The "/etc/hosts" file is already up to date.')
 
-- 
GitLab