<commit_before>#!/bin/bash

exec 1> >(logger -s -t $(basename $0)) 2>&1

set -e

export DIRECTORY_TO_COPY=$1

set -u

# The default Icinga passive alert assumes that the script failed
NAGIOS_CODE=2
NAGIOS_MESSAGE="CRITICAL: Push attachments to S3 failed"

# Triggered whenever this script exits, successful or otherwise. The values
# of CODE/MESSAGE will be taken from that point in time.
function nagios_passive () {
  printf "<%= @ipaddress %>\tPush attachments to S3\t${NAGIOS_CODE}\t${NAGIOS_MESSAGE}\n" | /usr/sbin/send_nsca -H <%= @alert_hostname %> >/dev/null
}

trap nagios_passive EXIT

usage() {
  echo "USAGE: $0 <directory_to_copy>"
  echo
  echo "Copies attachments in <directory_to_copy> to an S3 bucket"
  echo
  exit 1
}

if [ ! "$DIRECTORY_TO_COPY" ]; then
 usage
fi

if envdir /etc/govuk/aws/env.d /usr/local/bin/s3cmd --cache-file=/tmp/s3cmd_attachments.cache --server-side-encryption sync --exclude="lost+found" --skip-existing --delete-removed "$DIRECTORY_TO_COPY/" "s3://<%= @s3_bucket -%>$DIRECTORY_TO_COPY/"; then
  echo "Attachments copied to S3 (<%= @s3_bucket -%>) successfully"
else
  echo "Attachments errored while copying to S3 (<%= @s3_bucket -%>)"
fi

if [ $? == 0 ]
  then
    STATUS=0
  else
    STATUS=1
fi

if [ $STATUS -eq 0 ]; then
  NAGIOS_CODE=0
  NAGIOS_MESSAGE="Push attachments to S3 succeeded"
fi

exit $STATUS
<commit_msg>Disable nightly sync of Asset Manager assets from asset-slave-2 to S3<commit_after>#!/bin/bash

exec 1> >(logger -s -t $(basename $0)) 2>&1

set -e

export DIRECTORY_TO_COPY=$1

set -u

# The default Icinga passive alert assumes that the script failed
NAGIOS_CODE=2
NAGIOS_MESSAGE="CRITICAL: Push attachments to S3 failed"

# Triggered whenever this script exits, successful or otherwise. The values
# of CODE/MESSAGE will be taken from that point in time.
function nagios_passive () {
  printf "<%= @ipaddress %>\tPush attachments to S3\t${NAGIOS_CODE}\t${NAGIOS_MESSAGE}\n" | /usr/sbin/send_nsca -H <%= @alert_hostname %> >/dev/null
}

trap nagios_passive EXIT

usage() {
  echo "USAGE: $0 <directory_to_copy>"
  echo
  echo "Copies attachments in <directory_to_copy> to an S3 bucket"
  echo
  exit 1
}

if [ ! "$DIRECTORY_TO_COPY" ]; then
 usage
fi

if envdir /etc/govuk/aws/env.d /usr/local/bin/s3cmd --cache-file=/tmp/s3cmd_attachments.cache --server-side-encryption sync --exclude="lost+found" --exclude="asset-manager" --skip-existing --delete-removed "$DIRECTORY_TO_COPY/" "s3://<%= @s3_bucket -%>$DIRECTORY_TO_COPY/"; then
  echo "Attachments copied to S3 (<%= @s3_bucket -%>) successfully"
else
  echo "Attachments errored while copying to S3 (<%= @s3_bucket -%>)"
fi

if [ $? == 0 ]
  then
    STATUS=0
  else
    STATUS=1
fi

if [ $STATUS -eq 0 ]; then
  NAGIOS_CODE=0
  NAGIOS_MESSAGE="Push attachments to S3 succeeded"
fi

exit $STATUS

{'fraction_non_alphanumeric': 0.1327182398864443, 'fraction_numerical': 0.018452803406671398, 'mean_word_length': 4.097649186256781, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021865', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1031, 'n_words': 297}