diff --git a/scripts/common b/scripts/common new file mode 100644 index 0000000..39cca2f --- /dev/null +++ b/scripts/common @@ -0,0 +1,28 @@ +MAJOR="11" +REVISION="11.0" +FROMMAIL="Compose Tracker " +TOMAIL="releng@koozali.org" + +if ! which mm-compose-notif > /dev/null 2>&1; then + MM_NOTIF="" +else + MM_NOTIF="$(which mm-compose-notif)" +fi + +if ! which compose-changelog > /dev/null 2>&1; then + if [ -f "$HOME/.local/bin/compose-changelog" ]; then + CHANGELOG_CMD="$HOME/.local/bin/compose-changelog" + else + CHANGELOG_CMD="" + fi +else + CHANGELOG_CMD="$(which compose-changelog)" +fi + +if ! which mutt > /dev/null 2>&1; then + MAILCMD="" + MAILNOTIF="no" +else + MAILCMD="$(which mutt)" + MAILNOTIF="yes" +fi diff --git a/scripts/produce.sh b/scripts/produce.sh new file mode 100644 index 0000000..8870e15 --- /dev/null +++ b/scripts/produce.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +source "$(dirname "$0")/common" +export PATH=/usr/sbin:/usr/bin:/root/bin +TARGET_DIR="/mnt/compose/11" +LOG_DIR="/mnt/compose/logs" +SHORT=Rocky +CONFIG=/etc/pungi-prod/smeserver.conf +# Unused for now +OLDCOMPOSE_ID=$(cat $TARGET_DIR/latest-$SHORT-8/COMPOSE_ID) +SKIP="" +LABEL="--production --label RC-${REVISION}" + +CMD="pungi-koji --config=$CONFIG $SKIP $LABEL" +#COMPOSE_ID="smeserver-11-20240704.a.1" + +if [ -z "$COMPOSE_ID" ]; then + CMD="$CMD --target-dir=$TARGET_DIR" +else + CMD="$CMD --debug-mode --compose-dir=$TARGET_DIR/$COMPOSE_ID" +fi + +time $CMD +ret_val=$? + +if [[ "$ret_val" != "0" ]]; then + if [[ "$MAILNOTIF" == "yes" ]]; then + echo "This is a notification that a recent $SHORT compose failed on $(hostname)" | mutt -e "set from=\"$FROM\"" \ + -e 'set envelope_from=yes' \ + -s "Compose $NEWCOMPOSE_ID failed (for smeserver $REVISION)" \ + releng@koozali.org + fi + exit 1 +fi + +NEWCOMPOSE_ID="$(cat $TARGET_DIR/latest-$SHORT-$MAJOR/COMPOSE_ID)" +SHORTCOMPOSE_ID="$(echo $NEWCOMPOSE_ID | sed -e 's|smeserver-.*-||g')" + +# attempt to check changelog +if [ -n "$CHANGELOG_CMD" ]; then + if ! $CHANGELOG_CMD -p "$LOG_DIR/" "$TARGET_DIR/$OLDCOMPOSE_ID/" "$TARGET_DIR/$NEWCOMPOSE_ID" 2>"$LOG_DIR/changelog.$SHORTCOMPOSE_ID.stderr"; then + if [[ "$MAILNOTIF" == "yes" ]]; then + mutt -e "set from=\"$FROM\"" \ + -e 'set envelope_from=yes' \ + -s "Changelog for $NEWCOMPOSE_ID failed" \ + releng@koozali.org < "$LOG_DIR/changelog-$NEWCOMPOSE_ID.brief" + else + echo "!! Changelog run failed !!" + fi + exit 1 + fi +fi