Skip to content

Instantly share code, notes, and snippets.

@munds
Last active August 4, 2017 17:51
Show Gist options
  • Save munds/a51108da084f73a978df654afcd891c6 to your computer and use it in GitHub Desktop.
Save munds/a51108da084f73a978df654afcd891c6 to your computer and use it in GitHub Desktop.
Dynamic Scenario
#!/bin/bash
echo "Launching Raspberry Pi config in 5 seconds..."
echo "Please enable I2C under Interfacing Options or Advanced Options"
sleep 5
sudo raspi-config
echo "Thanks, human!"
echo ""
echo "Let's see if that worked..."
i2cdetect -y 1 &> /dev/null
STATUS=$?
echo "STATUS is $STATUS"
if [ $STATUS -eq 0 ]; then
echo "I2C detected, moving on!"
sleep 2
else
echo "I2C not enabled, please re-run this script."
exit
fi
echo ""
echo "Installing required linux packages ..."
sudo apt-get purge -y python-pip
sudo apt-get install -y python-dev python-smbus i2c-tools
sudo apt-get install -y pigpio python-pigpio python3-pigpio
sudo easy_install pip
echo ""
echo "Setting up wheeljack ..."
sleep 2
RESET=$1
if [ "$RESET" = "reset" ]; then
echo "Removing existing 'Development' folder ..."
sudo rm -rf /home/pi/Development
mkdir /home/pi/Development
else
echo "Keeping existing 'Development' folder ..."
fi
echo "Cloning wheeljack ..."
cd /home/pi/Development
if [ $? -ne 0 ]; then
echo "Creating Development directory"
mkdir -p /home/pi/Development
cd /home/pi/Development
sleep 2
fi
git clone https://github.com/PhysicalGraph/wheeljack.git
cd wheeljack
git checkout dynascene
yes | sudo pip uninstall wheeljack ; sudo pip install .
sudo pigpiod
sudo chmod +x /usr/local/bin/wheeljack
sudo systemctl enable wheeljack.service
echo ""
echo ""
echo "Wheeljack is now installed."
echo ""
echo "To start wheeljack, run:"
echo "sudo systemctl start wheeljack.service"
echo ""
echo "To stop wheeljack, run:"
echo "sudo systemctl stop wheeljack.service"
echo ""
echo "You can get status of wheeljack by running:"
echo "sudo systemctl status wheeljack.service"
echo ""
echo ""
sudo systemctl start wheeljack.service
sudo systemctl status wheeljack.service
echo ""
echo "Adding some shortcuts for easier management"
echo ""
echo "You will have a handful of commands that start with wj-"
echo ""
echo "wj-start : Start wheeljack"
echo "wj-stop : Stop wheeljack"
echo "wj-status : Status of wheeljack"
echo "wj-reload : Restart wheeljack (stop and then start again)"
echo "wj-logs : Logs from wheeljack"
echo ""
echo ""
echo "# Wheeljack aliases" >> ~/.bashrc
echo 'alias wj-start="sudo systemctl start wheeljack.service"' >> ~/.bashrc
echo 'alias wj-stop="sudo systemctl stop wheeljack.service"' >> ~/.bashrc
echo 'alias wj-status="sudo systemctl status wheeljack.service"' >> ~/.bashrc
echo 'alias wj-reload="sudo systemctl stop wheeljack.service && sudo systemctl start wheeljack.service"' >> ~/.bashrc
echo 'alias wj-logs="sudo tail -f /var/log/wheeljack.log"' >> ~/.bashrc
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment