<commit_before>#!/bin/sh

log()   { echo ">>> $1" ; }
warn()  { log "WARNING: $1" ; }
abort() { log "FATAL: $1" ; exit 1 ; }

HOSTNAME=
TMP_SALT_ROOT=/tmp/salt

# global args for running zypper
ZYPPER_GLOBAL_ARGS="-n --no-gpg-checks --quiet --no-color"

while [[ $# > 0 ]] ; do
  case $1 in
    --debug)
      set -x
      ;;
    -m|--salt-master)
      SALT_MASTER=$2
      shift
      ;;
    --tmp-salt-root)
      TMP_SALT_ROOT=$2
      shift
      ;;
    -h|--hostname)
      HOSTNAME=$2
      shift
      ;;
    *)
      abort "Unknown argument $1"
      ;;
  esac
  shift
done

###################################################################

if [ -n "$HOSTNAME" ] ; then
    log "Setting hostname $HOSTNAME"
    hostname $HOSTNAME
fi

log "Fixing the ssh keys permissions and setting the authorized keys"
chmod 600 /root/.ssh/*
cp -f /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys

log "Installing the Salt minion"
zypper $ZYPPER_GLOBAL_ARGS in --force-resolution --no-recommends salt-minion

if [ -n "$SALT_MASTER" ] ; then
    log "Setting salt master: $SALT_MASTER"
    log "master: $SALT_MASTER" > $TMP_SALT_ROOT/minion.d/minion.conf
else
    warn "no salt master set!"<commit_msg>Fixed a regression on minion provisioning<commit_after>#!/bin/sh

log()   { echo ">>> $1" ; }
warn()  { log "WARNING: $1" ; }
abort() { log "FATAL: $1" ; exit 1 ; }

HOSTNAME=
TMP_SALT_ROOT=/tmp/salt

# global args for running zypper
ZYPPER_GLOBAL_ARGS="-n --no-gpg-checks --quiet --no-color"

while [[ $# > 0 ]] ; do
  case $1 in
    --debug)
      set -x
      ;;
    -m|--salt-master)
      SALT_MASTER=$2
      shift
      ;;
    --tmp-salt-root)
      TMP_SALT_ROOT=$2
      shift
      ;;
    -h|--hostname)
      HOSTNAME=$2
      shift
      ;;
    *)
      abort "Unknown argument $1"
      ;;
  esac
  shift
done

###################################################################

if [ -n "$HOSTNAME" ] ; then
    log "Setting hostname $HOSTNAME"
    hostname $HOSTNAME
fi

log "Fixing the ssh keys permissions and setting the authorized keys"
chmod 600 /root/.ssh/*
cp -f /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys

log "Installing the Salt minion"
zypper $ZYPPER_GLOBAL_ARGS in --force-resolution --no-recommends salt-minion

if [ -n "$SALT_MASTER" ] ; then
    log "Setting salt master: $SALT_MASTER"
    echo "master: $SALT_MASTER" > $TMP_SALT_ROOT/minion.d/minion.conf
else
    warn "no salt master set!"
{'fraction_non_alphanumeric': 0.19298969072164948, 'fraction_numerical': 0.010721649484536083, 'mean_word_length': 2.6426426426426426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4809443', 'n_tokens_mistral': 937, 'n_tokens_neox': 887, 'n_words': 222}