<commit_before>#!/bin/bash
#  Copyright (c) 2015 - 2022, Intel Corporation
#  SPDX-License-Identifier: BSD-3-Clause
#

print_help() {
    echo "
    Usage: $0              - Kill main geopmd process
           $0 SESSION_PID  - Kill batch server process owned by session

    This helper script my be added to the suders file to give users running
    the integration tests permissions to kill geopmd processes.

"
    exit 0
}

kill_error() {
    echo "Error: $1" 1>&2
    exit -1
}


KILL_GEOPMD=0
if [[ $1 == '--help' ]]; then
    print_help
elif [[ ${USER} != "root" ]]; then
    kill_error "Script must be run as user root"
elif [[ $# -eq 0 ]]; then
    MAIN_PID=$(systemctl show geopm --property=MainPID | awk -F= '{print $2}')
    if [ ! -z "${MAIN_PID}" ] && ps ${MAIN_PID} >& /dev/null; then
        kill -9 ${MAIN_PID}
    else
        kill_error "Error: Unable to parse main PID from systemctl"
    fi
else
    SESSION_PID=$1
    BATCH_PID=$(sudo geopmaccess -s ${SESSION_PID} | \
            python3 -c 'import sys,json; print(json.loads(sys.stdin.read())["batch_server"])')
    if [ ! -z "${BATCH_PID}" ] && ps ${BATCH_PID} >& /dev/null; then
        kill -9 ${BATCH_PID}
    else<commit_msg>Fixup: delete unused variable<commit_after>#!/bin/bash
#  Copyright (c) 2015 - 2022, Intel Corporation
#  SPDX-License-Identifier: BSD-3-Clause
#

print_help() {
    echo "
    Usage: $0              - Kill main geopmd process
           $0 SESSION_PID  - Kill batch server process owned by session

    This helper script my be added to the suders file to give users running
    the integration tests permissions to kill geopmd processes.

"
    exit 0
}

kill_error() {
    echo "Error: $1" 1>&2
    exit -1
}


if [[ $1 == '--help' ]]; then
    print_help
elif [[ ${USER} != "root" ]]; then
    kill_error "Script must be run as user root"
elif [[ $# -eq 0 ]]; then
    MAIN_PID=$(systemctl show geopm --property=MainPID | awk -F= '{print $2}')
    if [ ! -z "${MAIN_PID}" ] && ps ${MAIN_PID} >& /dev/null; then
        kill -9 ${MAIN_PID}
    else
        kill_error "Error: Unable to parse main PID from systemctl"
    fi
else
    SESSION_PID=$1
    BATCH_PID=$(sudo geopmaccess -s ${SESSION_PID} | \
            python3 -c 'import sys,json; print(json.loads(sys.stdin.read())["batch_server"])')
    if [ ! -z "${BATCH_PID}" ] && ps ${BATCH_PID} >& /dev/null; then
        kill -9 ${BATCH_PID}
    else
{'fraction_non_alphanumeric': 0.1417910447761194, 'fraction_numerical': 0.019485903814262025, 'mean_word_length': 2.6285714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7372036', 'n_tokens_mistral': 883, 'n_tokens_neox': 824, 'n_words': 261}