3 # Copyright (c) 1999-2001 Jason Gunthorpe <jgg@debian.org>
4 # Copyright (c) 2002-2003,2006 Ryan Murray <rmurray@debian.org>
5 # Copyright (c) 2004-2005 Joey Schulze <joey@infodrom.org>
6 # Copyright (c) 2008,2011 Peter Palfrader <peter@palfrader.org>
7 # Copyright (c) 2008 Stephen Gran <sgran@debian.org>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # Without effect on the commandline
26 if [ -z "$TERM" -o "$TERM" = "dumb" ]
29 sleep $(( $RANDOM % 120 ))
45 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
48 SYNCHOST=`ud-config synchost`;
49 LOCALSYNCON=`ud-config localsyncon`;
50 EMAILAPPEND=`ud-config emailappend`;
53 if ! flock -w 60 -e 200; then
54 log "Cannot acquire lock on `pwd`"
65 udhost="sshdist@$SYNCHOST:"
72 if [ -e /var/lib/misc/thishost/dns-sshfp ]; then
73 cp /var/lib/misc/thishost/dns-sshfp $tempfile
76 if [ -e /var/lib/misc/thishost/dns-zone ]; then
77 cp /var/lib/misc/thishost/dns-zone $tempfile2
80 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" .
82 rm -f __db.passwd.db.t
83 makedb "$HOST/passwd.tdb" -o passwd.db.t
84 if [ -s "$HOST/shadow.tdb" ]
86 rm -f __db.shadow.db.t
87 (umask 027 && makedb "$HOST/shadow.tdb" -o shadow.db.t)
88 chown root.shadow shadow.db.t
89 chmod 0640 shadow.db.t
90 mv -f shadow.db.t shadow.db
93 makedb "$HOST/group.tdb" -o group.db.t
94 mv -f passwd.db.t passwd.db
95 mv -f group.db.t group.db
96 if [ -e "$HOST/ssh-rsa-shadow" ]; then
97 ln -sf $HOST/ssh-rsa-shadow .
98 ln -sf `pwd -P`/ssh-rsa-shadow /etc/ssh
100 rm -f ssh-rsa-shadow /etc/ssh/ssh-rsa-shadow
102 ln -sf $HOST/ssh_known_hosts .
103 ln -sf `pwd -P`/ssh_known_hosts /etc/ssh
105 if [ -e ${HOST}/ssh-keys.tar.gz ]; then
106 export TMPDIR='/tmp/'
108 tar -C "$tempdir" -xf ${HOST}/ssh-keys.tar.gz
111 rsync -a --delete-after $tempdir/ userkeys/
114 if [ -e ${HOST}/web-passwords ]; then
115 chown root:www-data ${HOST}/web-passwords
116 chmod 0640 ${HOST}/web-passwords
119 if [ -d "/etc/exim4" -a -e "$HOST/bsmtp" ]; then
120 if perl -e 'exit !((stat "/etc/exim4/bsmtp")[9] < time()-3600)'; then
121 cp "$HOST/bsmtp" /etc/exim4/bsmtp
124 if [ -d "/etc/postfix" -a -f "$HOST/forward-alias" ]; then
125 sed -e "s/:/@$EMAILAPPEND/" $HOST/forward-alias > /etc/postfix/debian
126 /usr/sbin/postmap hash:/etc/postfix/debian < /etc/postfix/debian || true
130 if [ -e /var/lib/misc/thishost/dns-sshfp ]; then
131 if ! cmp -s /var/lib/misc/thishost/dns-sshfp "$tempfile"; then
136 if [ -e /var/lib/misc/thishost/dns-zone ]; then
137 if ! cmp -s /var/lib/misc/thishost/dns-zone "$tempfile2"; then
142 if [ "${rebuild_zones}" -gt 0 ]; then
143 sudo -u dnsadm /srv/dns.debian.org/bin/update
146 if [ -d "/etc/freeradius" -a -e "$HOST/rtc-passwords" ]; then
147 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.freerad; then
148 install -o freerad -g freerad -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.freerad
149 service freeradius reload
152 if [ -d "/etc/reTurn" -a -e "$HOST/rtc-passwords" ]; then
153 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.return; then
154 install -o return -g return -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.return
155 service resiprocate-turn-server reload
158 if [ -d "/etc/prosody" -a -e "$HOST/rtc-passwords" ]; then
159 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.prosody; then
160 install -o prosody -g prosody -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.prosody
161 service prosody reload