<commit_before>#!/bin/bash

clear

echo -e "\033[31m"
echo "-----------------------------------------------------"
echo " ADS-B Exchange Feeder Setup Script. (Dump1090)"
echo "-----------------------------------------------------"
echo -e "\033[33m"
echo "ADSBexchange.com is a co-op of ADS-B/Mode S/MLAT feeders from around the world."
echo "This script will setup your feeder running Dump1090 to share your data with ADS-B Exchange as well."
echo ""
echo "https://github.com/jprochazka/adsb-exchange"
echo "http://www.adsbexchange.com/how-to-feed/"
echo "http://www.adsbexchange.com/forums/topic/ads-b-exchange-setup-script/"
echo -e "\033[37m"
read -p "Continue setup? [Y/n] " CONTINUE

if [[ $CONTINUE == "" ]]; then CONTINUE="Y"; fi
if [[ ! $CONTINUE =~ ^[Yy]$ ]]; then
    echo ""
    exit 0
fi

## ASSIGN THE SCRIPTDIR VARIABLE WHICH SHOULD BE THE DIRECTORY CONTAINING THIS SCRIPT

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

## SET PERMISSIONS ON THE ADS-B EXCHANGE MAINTAINANCE SCRIPT

echo -e "\033[33mSetting permissions on the ADS-B Exchange maintainance script..."
echo -e "\033[37m"
sudo chmod 755 $SCRIPTDIR/adsbexchange-maint.sh

## ADD ADS-B EXCHANGE MAINTAINANCE SCRIPT TO RC.LOCAL

if ! grep -Fxq "${SCRIPTDIR}/adsbexchange-maint.sh &" /etc/rc.local; then
    echo -e "\033[33mAdding 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 ${SCRIPTDIR}/adsbexchange-maint.sh &\n" /etc/rc.local
fi

## RUN THE ADS-B EXCHANGE MAINTAINANCE SCRIPT

echo -e "\033[33mRunning ADS-B Exchange maintainance script..."
echo -e "\033[37m"
sudo $SCRIPTDIR/adsbexchange-maint.sh start &

## DISPLAY SETUP COMPLETE MESSAGE

echo -e "\033[33m"
echo "Configuration of the ADS-B Exchange feed is now complete."
echo "Please look over the output generated to be sure no errors were encountered."
echo "Also make sure to leave the files and folders contained here in place."
echo -e "\033[37m"
read -p "Press enter to exit this script..." CONTINUE
echo ""

exit 0<commit_msg>Currently running maintenance scripts now killed.<commit_after>#!/bin/bash

clear

echo -e "\033[31m"
echo "-----------------------------------------------------"
echo " ADS-B Exchange Feeder Setup Script. (Dump1090)"
echo "-----------------------------------------------------"
echo -e "\033[33m"
echo "ADSBexchange.com is a co-op of ADS-B/Mode S/MLAT feeders from around the world."
echo "This script will setup your feeder running Dump1090 to share your data with ADS-B Exchange as well."
echo ""
echo "https://github.com/jprochazka/adsb-exchange"
echo "http://www.adsbexchange.com/how-to-feed/"
echo "http://www.adsbexchange.com/forums/topic/ads-b-exchange-setup-script/"
echo -e "\033[37m"
read -p "Continue setup? [Y/n] " CONTINUE

if [[ $CONTINUE == "" ]]; then CONTINUE="Y"; fi
if [[ ! $CONTINUE =~ ^[Yy]$ ]]; then
    echo ""
    exit 0
fi

## ASSIGN THE SCRIPTDIR VARIABLE WHICH SHOULD BE THE DIRECTORY CONTAINING THIS SCRIPT

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

## SET PERMISSIONS ON THE ADS-B EXCHANGE MAINTAINANCE SCRIPT

echo -e "\033[33mSetting permissions on the ADS-B Exchange maintainance script..."
echo -e "\033[37m"
sudo chmod 755 $SCRIPTDIR/adsbexchange-maint.sh

## ADD ADS-B EXCHANGE MAINTAINANCE SCRIPT TO RC.LOCAL

if ! grep -Fxq "${SCRIPTDIR}/adsbexchange-maint.sh &" /etc/rc.local; then
    echo -e "\033[33mAdding 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 ${SCRIPTDIR}/adsbexchange-maint.sh &\n" /etc/rc.local
fi

## KILL ANY CURRENTLY RUNNING INSTANCES OF THE ADS-B EXCHANGE MAINTAINANCE SCRIPT

echo -e "\033[33mKilling any adsbexchange-maint.sh processes currently running..."
PIDS=`ps -efww | grep -w "adsbexchange-maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'`
if [ ! -z "$PIDS" ]; then
    echo -e "\033[37m"
    sudo kill -9 $PIDS
    echo ""
fi

## RUN THE ADS-B EXCHANGE MAINTAINANCE SCRIPT

echo -e "\033[33mRunning ADS-B Exchange maintainance script..."
echo -e "\033[37m"
sudo $SCRIPTDIR/adsbexchange-maint.sh start &

## DISPLAY SETUP COMPLETE MESSAGE

echo -e "\033[33m"
echo "Configuration of the ADS-B Exchange feed is now complete."
echo "Please look over the output generated to be sure no errors were encountered."
echo "Also make sure to leave the files and folders contained here in place."
echo -e "\033[37m"
read -p "Press enter to exit this script..." CONTINUE
echo ""

exit 0
{'fraction_non_alphanumeric': 0.18623655913978496, 'fraction_numerical': 0.03376344086021505, 'mean_word_length': 3.076248904469763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2833789', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1609, 'n_words': 525}