6 # psuhpdo script for Debian
8 # Copyright (C) 2008 Joerg Jaspert <joerg@debian.org>
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation; version 2.
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # 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.
23 # In case the admin somehow wants to have this script located someplace else,
24 # he can set BASEDIR, and we will take that. If it is unset we take ${HOME}
25 BASEDIR
=${BASEDIR:-"${HOME}"}
30 # Read our config file
31 . "${BASEDIR}/etc
/${NAME}.conf
"
33 # Source our common functions
34 . "${BASEDIR}/etc
/common
"
36 # Set sane defaults if the configfile didn't do that for us.
37 # The directory for our logfiles
38 LOGDIR=${LOGDIR:-"${BASEDIR}/log"}
40 LOG
=${LOG:-"${LOGDIR}/${NAME}.log
"}
41 # How many logfiles to keep
42 LOGROTATE=${LOGROTATE:-14}
44 MIRRORS=${MIRRORS:-"${BASEDIR}/etc/${NAME}.mirror"}
46 PROGRAM
=${PROGRAM:-"${NAME}-$
(hostname
-s
)"}
47 # extra ssh options we might want hostwide
48 SSH_OPTS=${SSH_OPTS:-""}
49 # Which ssh key to use?
50 KEYFILE=${KEYFILE:-".ssh/pushpackages"}
51 # which path to "mirror
"
52 MIRRORPATH=${MIRRORPATH:-"/org/packages.debian.org/mirror/"}
53 # where to send mails to
54 if [ "x$
(hostname
-s
)x
" != "x
${MIRRORNAME%%.debian.org}x
" ]; then
55 # We are not on a debian.org host
56 MAILTO=${MAILTO:-"root"}
58 # Yay, on a .debian.org host
59 MAILTO=${MAILTO:-"mirrorlogs@debian.org"}
62 if ! [ -f "${BASEDIR}/${KEYFILE}" ]; then
63 error "SSH Key
${BASEDIR}/${KEYFILE} does not exist
" >> ${LOG}
71 # Make sure we have our log and lock directories
74 trap 'log "Pdopush
done" >> ${LOG}; savelog "${LOG}" > /dev/null' EXIT
76 log "Pushing pdo mirrors
" >> ${LOG}
78 # From here on we do *NOT* want to exit on errors. We don't want to
79 # stop pushing mirrors just because we can't reach one of them.
83 # Now read our mirrorfile and push the mirrors defined in there.
84 # We use grep to easily sort out all lines having a # in front of them or are empty.
85 egrep -v '^[[:space:]]*(#|$)' "${MIRRORS}" |
86 while read MLNAME MHOSTNAME MUSER MPROTO MKEYFILE; do
87 # Process the two options that can be left blank in the config
88 if [ -z ${MPROTO} ]; then
91 if [ -z ${MKEYFILE} ]; then
92 MKEYFILE="${BASEDIR}/${KEYFILE}"
94 # Now, people can do stupid things and leave out the protocol, but
96 if [ ${MPROTO} -ne 1 ] && [ ${MPROTO} -ne 2 ]; then
97 error "Need a correct
ssh protocol version
for ${MLNAME}, skipping
" >> ${LOG}
101 # And finally, push the mirror
102 log "Pushing
${MLNAME}" >> ${LOG}
103 # This needs a limited ssh key on the other side, something like
104 # no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="rsync
--server
-vlogDtpr .
/srv
/mirrors
/packages.debian.org
/",from="87.106.64.223,2001:8d8
:80:11::35d
,powell.debian.org
" ssh-rsa.....
105 rsync -e "ssh -i
${MKEYFILE} -${MPROTO} ${SSH_OPTS}" -av --stats "${MIRRORPATH}" ${MUSER}@${MHOSTNAME}:/does/not/matter >"${LOGDIR}/${MLNAME}.log
"
106 log "Pushing
${MLNAME} done" >> ${LOG}
107 savelog ${LOGDIR}${MLNAME}.log