Skip to content

Instantly share code, notes, and snippets.

@munds
Last active May 25, 2017 21:00
Show Gist options
  • Save munds/1e42b1d519af88eb2a57d0a8e66e80ce to your computer and use it in GitHub Desktop.
Save munds/1e42b1d519af88eb2a57d0a8e66e80ce to your computer and use it in GitHub Desktop.
#!/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 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
sudo pip install . --upgrade
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