2015-01-04 20:17:07 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# Download wpilib from github if the folder doesn't already exist
|
2015-01-05 18:23:58 -05:00
|
|
|
(test -d /vagrant/wpilib||(mkdir /vagrant/wpilib;curl -sL https://github.com/stonewareslord/wpilib/tarball/master | tar -xzC /vagrant/wpilib --strip-components=1))&
|
2015-01-04 20:17:07 -05:00
|
|
|
# Create the build folder if it doesn't already exist
|
2015-01-04 20:38:06 -05:00
|
|
|
mkdir -p /vagrant/build /vagrant/src
|
2015-01-04 20:17:07 -05:00
|
|
|
# Install the frc toolchain
|
|
|
|
add-apt-repository -y ppa:byteit101/frc-toolchain
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y frc-toolchain
|
|
|
|
# Compiles code in the /vagrant/src folder
|
2015-01-07 20:54:31 -05:00
|
|
|
echo "echo 'Starting build';(test -d /vagrant/src/Debug&&test -f /vagrant/src/Debug/makefile&&(cd /vagrant/src/Debug/&&make -f makefile clean;make -f makefile;cd -))||(test -f /vagrant/build/FRCUserProgram&&rm /vagrant/build/FRCUserProgram;test -f \`cat /vagrant/config/buildfile|head -n 1\`&&(arm-frc-linux-gnueabi-g++ -std=c++1y -I/vagrant/wpilib/include '-I/vagrant/src' -O0 -g3 -Wall -c -fmessage-length=0 -o /vagrant/build/Robot.o /vagrant/src/\`cat /vagrant/config/buildfile|head -n 1\`&&arm-frc-linux-gnueabi-g++ -L/vagrant/wpilib/lib -Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a -o /vagrant/build/FRCUserProgram /vagrant/build/Robot.o -lwpi;rm /vagrant/build/Robot.o))||(/home/vagrant/compile.sh);echo 'Done'" > /usr/local/bin/build
|
2015-01-04 20:17:07 -05:00
|
|
|
# Uploads the code to the rRIO based on /vagrant/config/host file
|
2015-01-07 20:54:31 -05:00
|
|
|
echo "cat /vagrant/build/FRCUserProgram | ssh \`cat /vagrant/config/host|head -n 1\` 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram;/usr/local/frc/bin/frcKillRobot.sh -t -r'||echo 'You probably haven\'t succesfully built yet. Run build to compile the program''" > /usr/local/bin/deploy
|
2015-01-04 20:17:07 -05:00
|
|
|
# Creates ssh key if it doesn't exist and cats the public key to the rRIO
|
2015-01-09 21:08:50 -05:00
|
|
|
echo "test -d ~/.ssh||mkdir ~/.ssh;test -f ~/.ssh/id_rsa||ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -q -N '';cat ~/.ssh/id_rsa.pub|ssh \`cat /vagrant/config/host|head -n 1\` 'cat >> /tmp/key;mkdir -p ~/.ssh;cat /tmp/key >> ~/.ssh/authorized_keys;rm /tmp/key'" > /usr/local/bin/putkey
|
2015-01-04 20:17:07 -05:00
|
|
|
chmod +x /usr/local/bin/build /usr/local/bin/deploy /usr/local/bin/putkey
|
|
|
|
echo "Done provisioning. Run vagrant ssh to connect to the virtual machine."
|