Index: trunk/dsys/comINSTALL
===================================================================
--- trunk/dsys/comINSTALL	(revision 1)
+++ trunk/dsys/comINSTALL	(revision 3)
@@ -340,7 +340,24 @@
     #---------------------------------------------------------------------
 
+    instlock="${yule_conf}.lockdir";
+    trap "rm -rf ${instlock}" 1 2 13 15
+
+    if test x"$simulate" = x0
+    then
+	#
+	# A lockfile will not work, because 'root' can write anyway.
+	# However, 'mkdir' an existing directory will fail even for root
+	#
+	until (umask 222; mkdir "${instlock}") 2>/dev/null   # test & set
+	do
+	   printINFO "Waiting for lock"
+	   sleep 1
+	done
+    fi
+
     Replace=`"${yule_exec}" -P "${is_passwd}" | sed s%HOSTNAME%${host}%g`
     if test "x$Replace" = x
     then
+	rm -rf "${instlock}"
 	printFATAL "Could not execute ${yule_exec} -P ${is_passwd}."
     fi
@@ -356,5 +373,9 @@
             then
 	        Seen=y
-		echo "$Replace" >>"$tmpF" || printFATAL "Cannot write new server configuration."
+		echo "$Replace" >>"$tmpF" 
+		if [ $? -ne 0 ]; then
+			rm -rf "${instlock}"
+			printFATAL "Cannot write new server configuration."
+		fi
 	    fi
         else
@@ -363,5 +384,9 @@
 		:
 	    else
-		echo "$line" >>"$tmpF" || printFATAL "Cannot write new server configuration."
+		echo "$line" >>"$tmpF"
+		if [ $? -ne 0 ]; then
+			rm -rf "${instlock}"
+			printFATAL "Cannot write new server configuration."
+		fi
             fi
         fi
@@ -380,8 +405,27 @@
     if test x"$simulate" = x0
     then
-        ageFILE "${yule_conf}" || printFATAL "Could not backup ${yule_conf}."
-        rm -f "${yule_conf}" && { cp "$tmpF"  "${yule_conf}" || printFATAL "Could not write new server config. Backup is ${yule_conf}.1"; }
-        chown ${rcfile_owner}:${rcfile_group} "${yule_conf}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
-        chmod ${rcfile_perm} "${yule_conf}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
+        ageFILE "${yule_conf}"
+	if [ $? -ne 0 ]; then
+		rm -rf "${instlock}"
+		printFATAL "Could not backup ${yule_conf}"
+	fi
+
+        rm -f "${yule_conf}" && cp "$tmpF"  "${yule_conf}"
+	if [ $? -ne 0 ]; then
+		rm -rf "${instlock}"
+		printFATAL "Could not write new server config. Backup is ${yule_conf}.1"
+	fi
+
+        chown ${rcfile_owner}:${rcfile_group} "${yule_conf}"
+	if [ $? -ne 0 ]; then
+		rm -rf "${instlock}"
+		printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
+	fi
+
+        chmod ${rcfile_perm} "${yule_conf}"
+	if [ $? -ne 0 ]; then
+		rm -rf "${instlock}"
+		printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
+	fi
     else
         printINFO "Backup and update ${yule_conf}"
@@ -423,4 +467,5 @@
 	sleep 5
 	#
+	rm -rf "${instlock}"
     else
         printINFO "Reloading server configuration."
@@ -428,4 +473,5 @@
 
     printLOG "Server configuration updated and reloaded."
+
 
     #---------------------------------------------------------------------
Index: trunk/dsys/funcINSTALL
===================================================================
--- trunk/dsys/funcINSTALL	(revision 1)
+++ trunk/dsys/funcINSTALL	(revision 3)
@@ -91,4 +91,18 @@
         DATABASE="${basedir}/${defdatabase}"
     fi
+
+    updlock="${DATABASE}.lockdir"
+    trap "rm -rf ${updlock}" 1 2 13 15
+
+    #
+    # A lockfile will not work, because 'root' can write anyway.
+    # However, 'mkdir' an existing directory will fail even for root
+    #
+    until (umask 222; mkdir "${updlock}") 2>/dev/null   # test & set
+    do
+       printINFO "Waiting for lock"
+       sleep 1
+    done
+
 
     IDATE=`date +"%Y-%m-%d %H:%M:%S"`
@@ -223,7 +237,16 @@
     fi
 
-    chown ${rcfile_owner}:${rcfile_group} "${DATABASE}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${DATABASE}"
-    chmod ${rcfile_perm} "${DATABASE}" || printFATAL "Could not chmod ${rcfile_perm} ${DATABASE}"
-
+    chown ${rcfile_owner}:${rcfile_group} "${DATABASE}"
+    if [ $? -ne 0 ]; then
+    	rm -rf "${instlock}"
+    	printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${DATABASE}"
+    fi
+    chmod ${rcfile_perm} "${DATABASE}"
+    if [ $? -ne 0 ]; then
+    	rm -rf "${instlock}"
+    	printFATAL "Could not chmod ${rcfile_perm} ${DATABASE}"
+    fi
+
+    rm -rf "${updlock}"
 }
 
