Replace all references to ftp.de.debian.org with cdn.debian.org
[grml-live.git] / buildd / functions.sh
index b658143..70f7287 100755 (executable)
@@ -1,3 +1,4 @@
+#!/bin/bash
 # Filename:      /usr/share/grml-live/buildd/functions.sh
 # Purpose:       main function file for grml-live buildd
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
@@ -12,7 +13,7 @@ die() {
 
 . /etc/grml/grml-buildd.conf || die "Could not source /etc/grml/grml-buildd.conf. Exiting."
 
-type -p mutt 1>/dev/null 2>&1 || die "mutt binary not found. Exiting."
+which mutt >/dev/null 2>&1 || die "mutt binary not found. Exiting."
 
 # exit if important variables aren't set:
 [ -n "$STORAGE" ]  || die "\$STORAGE is not set. Exiting."
@@ -23,12 +24,11 @@ type -p mutt 1>/dev/null 2>&1 || die "mutt binary not found. Exiting."
 
 # some defaults:
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
-DATE="$(date +%Y%m%d)"
+DATE=$(date +'%Y%m%d_%H%M%S')
 TMP_DIR="$(mktemp -d)"
 MUTT_HEADERS="$(mktemp)"
 [ -n "$TMP_DIR" ]      || die "Could not create \$TMP_DIR. Exiting."
 [ -n "$MUTT_HEADERS" ] || die "Could not create $\MUTT_HEADERS. Exiting."
-[ -n "$ARCH" ] && GRML_LIVE_ARCH="-a $ARCH"
 
 # make sure we have same safe defaults:
 [ -n "$OUTPUT_DIR" ]    || OUTPUT_DIR="${STORAGE}/grml-live_${DATE}.$$"
@@ -36,6 +36,7 @@ MUTT_HEADERS="$(mktemp)"
 [ -n "$RECIPIENT" ]     || RECIPIENT=root@localhost
 [ -n "$ATTACHMENT" ]    || ATTACHMENT="$TMP_DIR/grml-live-logs_$DATE.tar.gz"
 [ -n "$FROM" ]          || FROM=root@localhost
+[ -n "$ARCH" ]          || ARCH="$(dpkg --print-architecture)"
 
 if [ -n "$LOGFILE" ] ; then
    GRML_LOGFILE="$LOGFILE"
@@ -68,7 +69,7 @@ grml_live_run() {
   grml_name="$NAME-daily-$CODENAME"
   shortdate="$(date +%y%m%d)"
 
-  grml-live -F $* $GRML_LIVE_ARCH -s $SUITE -c $CLASSES -o $OUTPUT_DIR \
+  grml-live -F $* -a $ARCH -s $SUITE -c $CLASSES -o $OUTPUT_DIR \
             -g "$grml_name" -v "$shortdate" -r grml-live-autobuild -i $ISO_NAME \
             1>/var/log/grml-buildd.stdout \
             2>/var/log/grml-buildd.stderr ; RC=$?
@@ -89,8 +90,7 @@ create_logs() {
 # store logs on remote server:
 upload_logs() {
   [ -n "$RSYNC_MIRROR" ] || return 1
-  umask 002
-  rsync --exclude dmesg.log --times --partial --copy-links -az --quiet /var/log/grml-buildd.* \
+  rsync --exclude dmesg.log --times --partial --copy-links -rltDz --quiet /var/log/grml-buildd.* \
   $FAI_LOGFILES $GRML_LOGFILE $RSYNC_MIRROR/logs/"${NAME}_${DATE}"/
 }