<commit_before>#!/bin/bash
# Install standard software, do git configuration

# Each should only contain the packages that are added at that level
base="git python-yaml libzmq-dev python-zmq python-simplejson python-smbus python-virtualenv python-pip python-numpy"
extra="vim-nox ipython tmux screen nmap tree build-essential python-dev i2c-tools wireless-tools grc"

while getopts aubh opt; do
    case $opt in
        a)
            echo "Option: Additional packages"
            install_extra=true
            usb_opts="$usb_opts -a"
            ;;
        u)
            echo "Option: USB install"
            usb_install=true
            ;;
        b)
            echo "Option: Bot specific setup"
            bot_specific=true
            usb_opts="$usb_opts -b"
            ;;
        *)
            echo "Help"
            echo "  -a  Install additional packages: $extra"
            echo "  -u  Initiate install over USB"
            echo "  -b  Perform bot-specific setup (networking, etc)"
            exit 1
            ;;
  esac
done


if [ "$usb_install" = true ]; then
    bb=192.168.7.2
    ssh-keygen -R $bb >/dev/null 2>&1
    echo "Bootstrapping install over USB"
    dir=$(dirname $0)
    rsync -e "ssh -o StrictHostKeyChecking=no" -vr $dir root@${bb}:
    ssh -o StrictHostKeyChecking=no root@${bb} ./setup_bone.sh $usb_opts
    echo "Done with USB install"
    exit
fi

# Verify we're on an actual BeagleBone
if grep -q AM33XX /proc/cpuinfo; then
    echo "BeagleBone detected!"
else
    echo "This doesn't look like a BeagleBone!"
    echo "Aborting (use -u to connect over USB)"
    exit 1
fi

# TODO: add vimrc, bashrc, tmux.conf
echo "Populating filesystem..."
chown -R root.root fs-*
rsync -va fs-common/* /
if [ "bot_specific" = true ]; then
    rsync -va fs-bot/* /
    update-rc.d masquerade defaults
    echo Enabling uplink...
    ifup wlan1
    apt-get update
    echo
    echo "Installing hostap..."
    export DEBIAN_FRONTEND=noninteractive
    DPKG_OPTS=Dpkg::Options::="--force-confold"
    apt-get -y purge udhcpd
    apt-get -y -o ${DPKG_OPTS} install hostapd dnsmasq
    hostname -F /etc/hostname
else
    apt-get update
fi
chmod 600 /root/.ssh/id_rsa

update-rc.d bbb defaults
cp /usr/share/zoneinfo/America/New_York /etc/localtime

echo "Installing minimal package list: $base"
apt-get -y install $base
echo

if [ "$install_extra" = true ]; then
    echo "Installing extra packages: $extra"
    apt-get -y install $extra<commit_msg>Bugfix in setup_all.sh that broke bot-related setup<commit_after>#!/bin/bash
# Install standard software, do git configuration

# Each should only contain the packages that are added at that level
base="git python-yaml libzmq-dev python-zmq python-simplejson python-smbus python-virtualenv python-pip python-numpy"
extra="vim-nox ipython tmux screen nmap tree build-essential python-dev i2c-tools wireless-tools grc"

while getopts aubh opt; do
    case $opt in
        a)
            echo "Option: Additional packages"
            install_extra=true
            usb_opts="$usb_opts -a"
            ;;
        u)
            echo "Option: USB install"
            usb_install=true
            ;;
        b)
            echo "Option: Bot specific setup"
            bot_specific=true
            usb_opts="$usb_opts -b"
            ;;
        *)
            echo "Help"
            echo "  -a  Install additional packages: $extra"
            echo "  -u  Initiate install over USB"
            echo "  -b  Perform bot-specific setup (networking, etc)"
            exit 1
            ;;
  esac
done


if [ "$usb_install" = true ]; then
    bb=192.168.7.2
    ssh-keygen -R $bb >/dev/null 2>&1
    echo "Bootstrapping install over USB"
    dir=$(dirname $0)
    rsync -e "ssh -o StrictHostKeyChecking=no" -vr $dir root@${bb}:
    ssh -o StrictHostKeyChecking=no root@${bb} ./setup_bone.sh $usb_opts
    echo "Done with USB install"
    exit
fi

# Verify we're on an actual BeagleBone
if grep -q AM33XX /proc/cpuinfo; then
    echo "BeagleBone detected!"
else
    echo "This doesn't look like a BeagleBone!"
    echo "Aborting (use -u to connect over USB)"
    exit 1
fi

# TODO: add vimrc, bashrc, tmux.conf
echo "Populating filesystem..."
chown -R root.root fs-*
rsync -va fs-common/* /
if [ "$bot_specific" = true ]; then
    rsync -va fs-bot/* /
    update-rc.d masquerade defaults
    echo Enabling uplink...
    ifup wlan1
    apt-get update
    echo
    echo "Installing hostap..."
    export DEBIAN_FRONTEND=noninteractive
    DPKG_OPTS=Dpkg::Options::="--force-confold"
    apt-get -y purge udhcpd
    apt-get -y -o ${DPKG_OPTS} install hostapd dnsmasq
    hostname -F /etc/hostname
else
    apt-get update
fi
chmod 600 /root/.ssh/id_rsa

update-rc.d bbb defaults
cp /usr/share/zoneinfo/America/New_York /etc/localtime

echo "Installing minimal package list: $base"
apt-get -y install $base
echo

if [ "$install_extra" = true ]; then
    echo "Installing extra packages: $extra"
    apt-get -y install $extra
{'fraction_non_alphanumeric': 0.10086224182875476, 'fraction_numerical': 0.008020854220974533, 'mean_word_length': 2.3679945982444295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3471140', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1613, 'n_words': 519}