# Set $PROGRAM to a string to have it added to the output.
function log () {
local prefix=${PROGRAM:-}
- echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@"
+ echo "$(date +"%b %d %H:%M:%S") ${HOSTNAME} ${prefix}[$$]: $@"
}
# log the message using log() but then also send a mail
function log_error () {
log "$@"
if [ -z "${MAILTO}" ]; then
- echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${MAILTO}
+ echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@${HOSTNAME}] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${MAILTO}
fi
}
# Now we should make sure that we have a usable ${PROGRAM}.log, so
# append the $STAGEFILE.log to it.
- cat "${STAGEFILE}.log" >> "${LOGFILE}"
+ /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log"
rm -f "${STAGEFILE}.log"
log "########## ${PROGRAM} END: ${FUNC} ##########"
PROGRAM="dinstall_reboot"
# where do we want mails to go? For example log entries made with error()
-if [ "x$(hostname -s)x" != "xfranckx" ]; then
+if [[ ${HOSTNAME} != franck ]]; then
# Not our ftpmaster host
MAILTO=${MAILTO:-"root"}
else
exec >>/dev/null 2>&1
DATE=$(date -Is)
- cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[$(hostname -s)] Buildd key changes ${DATE}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" buildd-keys@ftp-master.debian.org
+ cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[${HOSTNAME}] Buildd key changes ${DATE}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" buildd-keys@ftp-master.debian.org
rm -f "${BUILDDFUN}"
}
# And the following types of cronscripts exists
declare -lr POSSIBLEARGS='+(unchecked|dinstall|hourly|daily|weekly|monthly|yearly)'
+declare -r HOSTNAME=$(hostname -s)
archs=$(dak admin a list | tr '\n' ' ')