<commit_before>#!/bin/bash

set -e

export BRANCH=${BRANCH:-<%= @manifests_branch %>}
export TMPDIR=${TMPDIR:-<%= @manifests_tmpdir %>}
export REPO=${REPO:-<%= @manifests_repo %>}
export BINPATH=${BINPATH:-<%= @manifests_binpath %>}
export MANIFESTSPATH=${MANIFESTSPATH:-<%= @manifests_manifestspath %>}
export MODULESPATH=${MODULESPATH:-<%= @manifests_modulespath %>}

(
  flock -n 9 || exit 1
  echo "Clean up..."
  rm -rf "${TMPDIR}"

  echo "Cloning..."
  git clone "${REPO}" "${TMPDIR}"
  cd "${TMPDIR}"
  git checkout "${BRANCH}"

  REVISION=`git log -1 HEAD | fgrep commit | awk '{print $NF}'`
  PREV_REVISION=`cat /tmp/puppet-manifests-revision.txt 2>/dev/null || echo -n none`
  echo -n "${REVISION}" > /tmp/puppet-manifests-revision.txt

  echo "Revision: \$Id: ${REVISION} \$"
  echo "Previous revision: ${PREV_REVISION}"

  if [[ "${REVISION}" == "${PREV_REVISION}" ]]; then
    echo "No updates found."
    exit 0
  fi

  sed -i 's~\$Id\$~\$Id: '${REVISION}' \$~' "${TMPDIR}/manifests/site.pp"

  git submodule init
  git submodule sync
  git submodule update

  echo "Linking..."
  rm -rf "${BINPATH}"
  rm -rf "${MANIFESTSPATH}"
  rm -rf "${MODULESPATH}"

  mv "${TMPDIR}/bin" "${BINPATH}"
  mv "${TMPDIR}/manifests" "${MANIFESTSPATH}"
  mv "${TMPDIR}/modules" "${MODULESPATH}"

  echo "Restarting UWSGI service to clear Puppet cache..."
  /usr/sbin/service uwsgi restart

) 9>/var/lock/puppet-manifests-update.lock<commit_msg>manifests update script fix<commit_after>#!/bin/bash

set -e

export BRANCH=${BRANCH:-<%= @manifests_branch %>}
export TMPDIR=${TMPDIR:-<%= @manifests_tmpdir %>}
export REPO=${REPO:-<%= @manifests_repo %>}
export BINPATH=${BINPATH:-<%= @manifests_binpath %>}
export MANIFESTSPATH=${MANIFESTSPATH:-<%= @manifests_manifestspath %>}
export MODULESPATH=${MODULESPATH:-<%= @manifests_modulespath %>}

(
  flock -n 9 || exit 1
  echo "Clean up..."
  rm -rf "${TMPDIR}"

  echo "Cloning..."
  git clone "${REPO}" "${TMPDIR}"
  cd "${TMPDIR}"
  git checkout "${BRANCH}"

  REVISION=`git rev-parse HEAD`
  PREV_REVISION=`cat /var/lib/puppet/revision.txt 2>/dev/null || echo -n none`

  echo "Revision: ${REVISION}"
  echo "Previous revision: ${PREV_REVISION}"

  if [[ "${REVISION}" == "${PREV_REVISION}" ]]; then
    echo "No updates found."
    exit 0
  fi

  echo -n "${REVISION}" > /var/lib/puppet/revision.txt
  sed -i 's~\$Id\$~\$Id: '${REVISION}' \$~' "${TMPDIR}/manifests/site.pp"

  git submodule init
  git submodule sync
  git submodule update

  echo "Linking..."
  rm -rf "${BINPATH}"
  rm -rf "${MANIFESTSPATH}"
  rm -rf "${MODULESPATH}"

  mv "${TMPDIR}/bin" "${BINPATH}"
  mv "${TMPDIR}/manifests" "${MANIFESTSPATH}"
  mv "${TMPDIR}/modules" "${MODULESPATH}"

  echo "Restarting UWSGI service to clear Puppet cache..."
  /usr/sbin/service uwsgi restart

) 9>/var/lock/puppet-manifests-update.lock
{'fraction_non_alphanumeric': 0.2024604569420035, 'fraction_numerical': 0.003866432337434095, 'mean_word_length': 4.100358422939068, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '3022901', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1085, 'n_words': 249}