<commit_before>#!/bin/bash

# Check if user is using sudo or is logged in a root.
if [ "$(id -u)" != "0" ]; then
    echo "This script must be ran using sudo or as root."
    exit 1
fi

clear

# Set a variable containing the path to this script.
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

##############
## FUNCTIONS

# Configure FlightAware's PiAware software.
function ConfigurePiAware() {
    # Retreive and clean the current PiAware mlatResultFormat setting.
    echo -e "\033[33m"
    echo "Adding the ADS-B Exchange feed to PiAware's configuration..."
    ORIGINALFORMAT="`sudo piaware-config -show mlat-results-format`"
    CLEANFORMAT=`sed 's/ beast,connect,feed.adsbexchange.com:30005//g' <<< $ORIGINALFORMAT`
    FINALFORMAT="${CLEANFORMAT} beast,connect,feed.adsbexchange.com:30005"

    # Set the new PiAware mlatResultFormat setting.
    sudo piaware-config  mlat-results-format "${FINALFORMAT}"

    # Restart PiAware.
    echo ""
    echo "Restarting PiAware so new configuration takes effect..."
    echo -e "\033[37m"
    sudo piaware-config -restart
}

# Setup the Netcat script and execute it.
function SetupNetcat() {
    # Check if netcat is installed and if not install it.
    printf "\033[33mChecking if the package $1 is installed..."
    if [ $(dpkg-query -W -f='${STATUS}' netcat 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
        echo -e "\033[33m"
        echo "Installing the Netcat package..."
        echo -e "\033[37m"
        sudo apt-get install netcat
    fi
    
    # Set permissions on the file adsbexchange-maint.sh.
    chmod 755 $SCRIPTPATH/adsbexchange-maint.sh

    # Add the ADS-B maintainance script to the file /etc/rc.local.
    if ! grep -Fxq "${SCRIPTPATH}/adsbexchange-maint.sh &" /etc/rc.local; then
        echo -e "\033[33m"
        echo "Adding ADS-B Exchange maintainance script startup command to rc.local..."
        echo -e "\033[37m"
        lnum=($(sed -n '/exit 0/=' /etc/rc.local))
        ((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${SCRIPTPATH}/adsbexchange-maint.sh &\n" /etc/rc.local
    fi
<commit_msg>Added -y to skip confirmation.<commit_after>#!/bin/bash

# Check if user is using sudo or is logged in a root.
if [ "$(id -u)" != "0" ]; then
    echo "This script must be ran using sudo or as root."
    exit 1
fi

clear

# Set a variable containing the path to this script.
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

##############
## FUNCTIONS

# Configure FlightAware's PiAware software.
function ConfigurePiAware() {
    # Retreive and clean the current PiAware mlatResultFormat setting.
    echo -e "\033[33m"
    echo "Adding the ADS-B Exchange feed to PiAware's configuration..."
    ORIGINALFORMAT="`sudo piaware-config -show mlat-results-format`"
    CLEANFORMAT=`sed 's/ beast,connect,feed.adsbexchange.com:30005//g' <<< $ORIGINALFORMAT`
    FINALFORMAT="${CLEANFORMAT} beast,connect,feed.adsbexchange.com:30005"

    # Set the new PiAware mlatResultFormat setting.
    sudo piaware-config  mlat-results-format "${FINALFORMAT}"

    # Restart PiAware.
    echo ""
    echo "Restarting PiAware so new configuration takes effect..."
    echo -e "\033[37m"
    sudo piaware-config -restart
}

# Setup the Netcat script and execute it.
function SetupNetcat() {
    # Check if netcat is installed and if not install it.
    printf "\033[33mChecking if the package $1 is installed..."
    if [ $(dpkg-query -W -f='${STATUS}' netcat 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
        echo -e "\033[33m"
        echo "Installing the Netcat package..."
        echo -e "\033[37m"
        sudo apt-get install -y netcat
    fi
    
    # Set permissions on the file adsbexchange-maint.sh.
    chmod 755 $SCRIPTPATH/adsbexchange-maint.sh

    # Add the ADS-B maintainance script to the file /etc/rc.local.
    if ! grep -Fxq "${SCRIPTPATH}/adsbexchange-maint.sh &" /etc/rc.local; then
        echo -e "\033[33m"
        echo "Adding ADS-B Exchange maintainance script startup command to rc.local..."
        echo -e "\033[37m"
        lnum=($(sed -n '/exit 0/=' /etc/rc.local))
        ((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${SCRIPTPATH}/adsbexchange-maint.sh &\n" /etc/rc.local
    fi

{'fraction_non_alphanumeric': 0.14248704663212436, 'fraction_numerical': 0.026848798869524258, 'mean_word_length': 2.9433611884865365, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '1012322', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1421, 'n_words': 447}