ud-mailgate: remove exception for münchen.debian.net
[mirror/userdir-ldap.git] / ud-replicate
index 26158b9..53867e7 100755 (executable)
@@ -37,7 +37,6 @@ tempfile2=''
 
 cleanup ()
 {
-  rm -f lock
   rm -rf $tempdir
   rm -f  $tempfile
   rm -f  $tempfile2
@@ -49,9 +48,13 @@ HOST=`hostname -f`
 SYNCHOST=`ud-config synchost`;
 LOCALSYNCON=`ud-config localsyncon`;
 EMAILAPPEND=`ud-config emailappend`;
-cd /tmp/
-cd /var/lib/misc || cd /var/state/glibc/ || cd /var/db/
-lockfile -r 1 -l 3600 lock
+cd /var/lib/misc
+exec 200< "."
+if ! flock -w 60 -e 200; then
+    log "Cannot acquire lock on `pwd`"
+    exit 1
+fi
+
 trap cleanup exit
 
 case $HOST in
@@ -76,14 +79,17 @@ fi
 
 rsync ${verbose} --delete-after --times -e 'ssh -i /etc/ssh/ssh_host_rsa_key -o ControlPath=/var/run/.ud-replicate.ssh.socket -o ControlMaster=auto -o ControlPersist=2h -o BatchMode=yes' -rp "${udhost}/var/cache/userdir-ldap/hosts/$HOST" .
 
+rm -f __db.passwd.db.t
 makedb "$HOST/passwd.tdb" -o passwd.db.t
 if [ -s "$HOST/shadow.tdb" ]
 then
+    rm -f __db.shadow.db.t
     (umask 027 && makedb "$HOST/shadow.tdb" -o shadow.db.t)
     chown root.shadow shadow.db.t
     chmod 0640 shadow.db.t
     mv -f shadow.db.t shadow.db
 fi
+rm -f __db.group.db.t
 makedb "$HOST/group.tdb" -o group.db.t
 mv -f passwd.db.t passwd.db
 mv -f group.db.t group.db