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 makedb "$HOST/passwd.tdb" -o passwd.db.t
83 if [ -s "$HOST/shadow.tdb" ]
85 (umask 027 && makedb "$HOST/shadow.tdb" -o shadow.db.t)
86 chown root.shadow shadow.db.t
87 chmod 0640 shadow.db.t
88 mv -f shadow.db.t shadow.db
90 makedb "$HOST/group.tdb" -o group.db.t
91 mv -f passwd.db.t passwd.db
92 mv -f group.db.t group.db
93 if [ -e "$HOST/ssh-rsa-shadow" ]; then
94 ln -sf $HOST/ssh-rsa-shadow .
95 ln -sf `pwd -P`/ssh-rsa-shadow /etc/ssh
97 rm -f ssh-rsa-shadow /etc/ssh/ssh-rsa-shadow
99 ln -sf $HOST/ssh_known_hosts .
100 ln -sf `pwd -P`/ssh_known_hosts /etc/ssh
102 if [ -e ${HOST}/ssh-keys.tar.gz ]; then
103 export TMPDIR='/tmp/'
105 tar -C "$tempdir" -xf ${HOST}/ssh-keys.tar.gz
108 rsync -a --delete-after $tempdir/ userkeys/
111 if [ -e ${HOST}/web-passwords ]; then
112 chown root:www-data ${HOST}/web-passwords
113 chmod 0640 ${HOST}/web-passwords
116 if [ -d "/etc/exim4" -a -e "$HOST/bsmtp" ]; then
117 if perl -e 'exit !((stat "/etc/exim4/bsmtp")[9] < time()-3600)'; then
118 cp "$HOST/bsmtp" /etc/exim4/bsmtp
121 if [ -d "/etc/postfix" -a -f "$HOST/forward-alias" ]; then
122 sed -e "s/:/@$EMAILAPPEND/" $HOST/forward-alias > /etc/postfix/debian
123 /usr/sbin/postmap hash:/etc/postfix/debian < /etc/postfix/debian || true
127 if [ -e /var/lib/misc/thishost/dns-sshfp ]; then
128 if ! cmp -s /var/lib/misc/thishost/dns-sshfp "$tempfile"; then
133 if [ -e /var/lib/misc/thishost/dns-zone ]; then
134 if ! cmp -s /var/lib/misc/thishost/dns-zone "$tempfile2"; then
139 if [ "${rebuild_zones}" -gt 0 ]; then
140 sudo -u dnsadm /srv/dns.debian.org/bin/update
143 if [ -d "/etc/freeradius" -a -e "$HOST/rtc-passwords" ]; then
144 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.freerad; then
145 install -o freerad -g freerad -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.freerad
146 service freeradius reload
149 if [ -d "/etc/reTurn" -a -e "$HOST/rtc-passwords" ]; then
150 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.return; then
151 install -o return -g return -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.return
152 service resiprocate-turn-server reload
155 if [ -d "/etc/prosody" -a -e "$HOST/rtc-passwords" ]; then
156 if ! cmp -s "$HOST/rtc-passwords" /var/local/rtc-passwords.prosody; then
157 install -o prosody -g prosody -m 400 "$HOST/rtc-passwords" /var/local/rtc-passwords.prosody
158 service prosody reload