<commit_before>#!/bin/bash
JAVA_HOME=${JAVA_HOME:-/opt/java/java-current}
BOUNCER_HOME=${BOUNCER_HOME:-/opt/bouncer}
BOUNCER_CONF=${BOUNCER_CONF:-bouncer.conf}
BOUNCER_CLASSPATH=$(echo $BOUNCER_HOME/lib/*.jar | tr ' ' ':')
#
do_reload () {
  touch ${BOUNCER_HOME}/conf/${BOUNCER_CONF}
}
do_keygen () {
  # org.javastack.bouncer.KeyGenerator <bits> <days> <CommonName> <filename-without-extension>
  local bits="${1}" days="${2}" cn="${3}" filebase="${4}"
  if [ "$filebase" = "" ]; then
    echo "$0 keygen <bits> <days> <CommonName> <filename-without-extension>"
    echo "Sample:"
    echo "$0 keygen 2048 365 host1.acme.com host1"
    exit 1;
  fi
  cd "${BOUNCER_HOME}/keys/"
  ${JAVA_HOME}/bin/java \
    -cp "${BOUNCER_CLASSPATH}" \
    org.javastack.bouncer.KeyGenerator $bits $days $cn $filebase
  #chmod go-rwx "${filebase}.key"
  ls -al "${BOUNCER_HOME}/keys/${filebase}."*
}
do_start () {
  cd ${BOUNCER_HOME}
  nohup ${JAVA_HOME}/bin/java -Dprogram.name=bouncer -Xmx64m \
    -cp "${BOUNCER_HOME}/conf/:${BOUNCER_HOME}/keys/:${BOUNCER_CLASSPATH}" \
    -Dlog.stdOutFile=${BOUNCER_HOME}/log/bouncer.out \
    -Dlog.stdErrFile=${BOUNCER_HOME}/log/bouncer.err \
    org.javastack.bouncer.Bouncer 1>${BOUNCER_HOME}/log/bouncer.bootstrap 2>&1 &
  PID="$!"
  echo "Bouncer: STARTED [${PID}]"
}
do_stop () {
  PID="$(ps axwww | grep "program.name=bouncer" | grep -v grep | while read _pid _r; do echo ${_pid}; done)"
  if [ "${PID}" = "" ]; then
    echo "Bouncer: NOT RUNNING"
  else
    echo -n "Bouncer: KILLING [${PID}]"
    kill -TERM ${PID}
    echo -n "["
    while [ -f "/proc/${PID}/status" ]; do
      echo -n "."
      sleep 1
    done
    echo "]"
  fi
}
do_status () {
  PID="$(ps axwww | grep "program.name=bouncer" | grep -v grep | while read _pid _r; do echo ${_pid}; done)"
  if [ "${PID}" = "" ]; then
    echo "Bouncer: NOT RUNNING"
  else
    echo "Bouncer: RUNNING [${PID}]"
  fi
}
case "$1" in
  start)
    do_stop
    do_start
  ;;
  stop)
    do_stop
  ;;
  restart)
    do_stop
    do_start
  ;;
  reload)
    do_reload
  ;;
  status)
    do_status
  ;;
  keygen)
    do_keygen $2 $3 $4 $5
  ;;
  *)
    echo "$0 <start|stop|restart|reload|status|keygen>"
  ;;
esac<commit_msg>remove JAVA_HOME dependency and allow run foreground<commit_after>#!/bin/bash
BOUNCER_HOME=${BOUNCER_HOME:-/opt/bouncer}
BOUNCER_CONF=${BOUNCER_CONF:-bouncer.conf}
BOUNCER_CLASSPATH=$(echo $BOUNCER_HOME/lib/*.jar | tr ' ' ':')
#
do_reload () {
  touch ${BOUNCER_HOME}/conf/${BOUNCER_CONF}
}
do_keygen () {
  # org.javastack.bouncer.KeyGenerator <bits> <days> <CommonName> <filename-without-extension>
  local bits="${1}" days="${2}" cn="${3}" filebase="${4}"
  if [ "$filebase" = "" ]; then
    echo "$0 keygen <bits> <days> <CommonName> <filename-without-extension>"
    echo "Sample:"
    echo "$0 keygen 2048 365 host1.acme.com host1"
    exit 1;
  fi
  cd "${BOUNCER_HOME}/keys/"
  java \
    -cp "${BOUNCER_CLASSPATH}" \
    org.javastack.bouncer.KeyGenerator $bits $days $cn $filebase
  #chmod go-rwx "${filebase}.key"
  ls -al "${BOUNCER_HOME}/keys/${filebase}."*
}
do_run () {
  cd ${BOUNCER_HOME}
  java -Dprogram.name=bouncer -Xmx64m \
    -cp "${BOUNCER_HOME}/conf/:${BOUNCER_HOME}/keys/:${BOUNCER_CLASSPATH}" \
    org.javastack.bouncer.Bouncer
}
do_start () {
  cd ${BOUNCER_HOME}
  nohup java -Dprogram.name=bouncer -Xmx64m \
    -cp "${BOUNCER_HOME}/conf/:${BOUNCER_HOME}/keys/:${BOUNCER_CLASSPATH}" \
    -Dlog.stdOutFile=${BOUNCER_HOME}/log/bouncer.out \
    -Dlog.stdErrFile=${BOUNCER_HOME}/log/bouncer.err \
    org.javastack.bouncer.Bouncer 1>${BOUNCER_HOME}/log/bouncer.bootstrap 2>&1 &
  PID="$!"
  echo "Bouncer: STARTED [${PID}]"
}
do_stop () {
  PID="$(ps axwww | grep "program.name=bouncer" | grep -v grep | while read _pid _r; do echo ${_pid}; done)"
  if [ "${PID}" = "" ]; then
    echo "Bouncer: NOT RUNNING"
  else
    echo -n "Bouncer: KILLING [${PID}]"
    kill -TERM ${PID}
    echo -n "["
    while [ -f "/proc/${PID}/status" ]; do
      echo -n "."
      sleep 1
    done
    echo "]"
  fi
}
do_status () {
  PID="$(ps axwww | grep "program.name=bouncer" | grep -v grep | while read _pid _r; do echo ${_pid}; done)"
  if [ "${PID}" = "" ]; then
    echo "Bouncer: NOT RUNNING"
  else
    echo "Bouncer: RUNNING [${PID}]"
  fi
}
case "$1" in
  run)
    do_stop
    trap do_stop SIGINT SIGTERM
    do_run
  ;;
  start)
    do_stop
    do_start
  ;;
  stop)
    do_stop
  ;;
  restart)
    do_stop
    do_start
  ;;
  reload)
    do_reload
  ;;
  status)
    do_status
  ;;
  keygen)
    do_keygen $2 $3 $4 $5
  ;;
  *)
    echo "$0 <run|start|stop|restart|reload|status|keygen>"
  ;;
esac
{'fraction_non_alphanumeric': 0.18535320803629293, 'fraction_numerical': 0.012529704039749406, 'mean_word_length': 3.255514705882353, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4845459', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1948, 'n_words': 374}