<commit_before>#!/bin/bash
set -e

unset "DAEMON_OPTS[${#DAEMON_OPTS[@]}-1]" # remove the last element of the array
OSD_PATH="/var/lib/ceph/osd/${CLUSTER}-0"
PREPARE_OSD=$OSD_PATH
ACTIVATE_OSD=$OSD_PATH
MDS_PATH="/var/lib/ceph/mds/${CLUSTER}-0"
RGW_PATH="/var/lib/ceph/radosgw/${CLUSTER}-rgw.${RGW_NAME}"
MGR_PATH="/var/lib/ceph/mgr/${CLUSTER}-$MGR_NAME"
RESTAPI_IP=$MON_IP
MGR_IP=$MON_IP
: "${DEMO_DAEMONS:=all}"
: "${RGW_ENABLE_USAGE_LOG:=true}"
: "${RGW_USAGE_MAX_USER_SHARDS:=1}"
: "${RGW_USAGE_MAX_SHARDS:=32}"
: "${RGW_USAGE_LOG_FLUSH_THRESHOLD:=1}"
: "${RGW_USAGE_LOG_TICK_INTERVAL:=1}"


#######
# MON #
#######
function bootstrap_mon {
  # shellcheck disable=SC1091
  source start_mon.sh
  start_mon

  chown --verbose ceph. /etc/ceph/*
}


#######
# OSD #
#######
function bootstrap_osd {
  if [ ! -e "$OSD_PATH"/keyring ]; then
    # bootstrap OSD
    mkdir -p "$OSD_PATH"
    chown --verbose -R ceph. "$OSD_PATH"
    if [[ -n "$OSD_DEVICE" ]]; then
      PREPARE_OSD=$OSD_DEVICE
      if [[ -b "$OSD_DEVICE" ]]; then
        ACTIVATE_OSD=${OSD_DEVICE}1
      elif [[ -d "$OSD_DEVICE" ]]; then
        ACTIVATE_OSD=${OSD_DEVICE}
      else
        echo "Invalid $OSD_DEVICE, only directory and block device are supported"
      fi
    fi
    ceph-disk -v prepare "${CLI_OPTS[@]}" --bluestore "$PREPARE_OSD"
    chown --verbose -R ceph. "$PREPARE_OSD"*
    ceph-disk -v activate --mark-init none --no-start-daemon "$ACTIVATE_OSD"
  fi

  # start OSD
  chown --verbose -R ceph. "$OSD_PATH"
  ceph-osd "${DAEMON_OPTS[@]}" -i 0
}


#######<commit_msg>demo: add "osd_data" config to ceph.conf<commit_after>#!/bin/bash
set -e

unset "DAEMON_OPTS[${#DAEMON_OPTS[@]}-1]" # remove the last element of the array
OSD_PATH="/var/lib/ceph/osd/${CLUSTER}-0"
PREPARE_OSD=$OSD_PATH
ACTIVATE_OSD=$OSD_PATH
MDS_PATH="/var/lib/ceph/mds/${CLUSTER}-0"
RGW_PATH="/var/lib/ceph/radosgw/${CLUSTER}-rgw.${RGW_NAME}"
MGR_PATH="/var/lib/ceph/mgr/${CLUSTER}-$MGR_NAME"
RESTAPI_IP=$MON_IP
MGR_IP=$MON_IP
: "${DEMO_DAEMONS:=all}"
: "${RGW_ENABLE_USAGE_LOG:=true}"
: "${RGW_USAGE_MAX_USER_SHARDS:=1}"
: "${RGW_USAGE_MAX_SHARDS:=32}"
: "${RGW_USAGE_LOG_FLUSH_THRESHOLD:=1}"
: "${RGW_USAGE_LOG_TICK_INTERVAL:=1}"


#######
# MON #
#######
function bootstrap_mon {
  # shellcheck disable=SC1091
  source start_mon.sh
  start_mon

  chown --verbose ceph. /etc/ceph/*
}


#######
# OSD #
#######
function bootstrap_osd {
  if [ ! -e "$OSD_PATH"/keyring ]; then
    # bootstrap OSD
    mkdir -p "$OSD_PATH"
    chown --verbose -R ceph. "$OSD_PATH"
    if [[ -n "$OSD_DEVICE" ]]; then
      PREPARE_OSD=$OSD_DEVICE
      if [[ -b "$OSD_DEVICE" ]]; then
        ACTIVATE_OSD=${OSD_DEVICE}1
      elif [[ -d "$OSD_DEVICE" ]]; then
        if ! grep -qE "osd data = $OSD_DEVICE" /etc/ceph/"${CLUSTER}".conf; then
          echo "osd data = $OSD_DEVICE" >> /etc/ceph/"${CLUSTER}".conf
        fi
        ACTIVATE_OSD=${OSD_DEVICE}
      else
        echo "Invalid $OSD_DEVICE, only directory and block device are supported"
      fi
    fi
    ceph-disk -v prepare "${CLI_OPTS[@]}" --bluestore "$PREPARE_OSD"
    chown --verbose -R ceph. "$PREPARE_OSD"*
    ceph-disk -v activate --mark-init none --no-start-daemon "$ACTIVATE_OSD"
  fi

  # start OSD
  chown --verbose -R ceph. "$OSD_PATH"
  ceph-osd "${DAEMON_OPTS[@]}" -i 0
}


#######
{'fraction_non_alphanumeric': 0.190865093768905, 'fraction_numerical': 0.008469449485783424, 'mean_word_length': 3.644662921348315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3054309', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1417, 'n_words': 245}