Last active
February 2, 2016 05:12
-
-
Save brysonreece/723fa672500c16b82871 to your computer and use it in GitHub Desktop.
A Quick-Setup Script for OU-Innovation-HHA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$EUID" -ne 0 ] | |
| then echo "Argh! You're not root! Walk the plank!" | |
| exit | |
| fi | |
| printf "Please wait, installing packages..." | |
| # Add OpenHAB to our downloadable package list | |
| wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' |sudo apt-key add - | |
| echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list | |
| # Gotta make sure our packages are up to date! | |
| apt-get update && sudo apt-get upgrade -y | |
| # Let's install some prerequisites. | |
| apt-get install git git-core maven openhab-runtime -y | |
| # We're going to do this in the tmp folder so our downloads erase on boot. | |
| cd /tmp | |
| # We'll start by installing wiringPi, a library for interacting with our GPIO pins. | |
| rm -rf wiringPi | |
| git clone git://git.drogon.net/wiringPi && cd wiringPi | |
| git pull origin | |
| ./build | |
| cd .. && rm -rf wiringPi | |
| # Now we're go to move on to installing the tools to communicate with our outlets. | |
| rm -rf rf-utils | |
| git clone https://github.com/brysonreece/rf-utils.git && cd rf-utils | |
| mv codesend /usr/bin/codesend | |
| mv RFSniffer /usr/bin/codeget | |
| chown root.root /usr/bin/codesend | |
| chown root.root /usr/bin/codeget | |
| chmod 4755 /usr/bin/codesend | |
| chmod 4755 /usr/bin/codeget | |
| cd .. && rm -rf rf-utils | |
| # Now we move on to initializing OpenHAB | |
| update-rc.d openhab defaults | |
| # Adding the default addons and configurations to our OpenHAB installation | |
| rm -rf openhab | |
| wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.0-demo.zip --local-encoding=UTF-8 | |
| unzip distribution-1.8.0-demo.zip -d openhab/ && rm -rf distribution-1.8.0-demo.zip | |
| cd openhab | |
| rm -rf /etc/openhab/configurations && sudo rm -rf /usr/share/openhab/addons | |
| mv configurations/ /etc/openhab/ && sudo mv addons /usr/share/openhab | |
| rm -rf /etc/openhab/configurations/sitemaps/demo.sitemap | |
| rm -rf /etc/openhab/configurations/items/demo.items | |
| # We're going to use a sitemap and itemmap I made specifically for this course for ease of setup. | |
| git clone https://github.com/brysonreece/openhab-hha.git && cd openhab-hha | |
| cp default.sitemap /etc/openhab/configurations/sitemaps/ | |
| cp default.items /etc/openhab/configurations/items/ | |
| # Fixes some OpenHAB permissions | |
| chown -hR openhab:openhab /etc/openhab && sudo chown -hR openhab:openhab /usr/share/openhab | |
| chmod -R 755 /etc/openhab/ && sudo chmod -R 755 /usr/share/openhab/ | |
| # Makes sure we're still in /tmp | |
| cd /tmp | |
| rm -rf /tmp/* | |
| # Let's install the Echo Bridge! This allows our Echo to run commands on our Pi | |
| rm -rf echo-bridge | |
| git clone https://github.com/brysonreece/echo-bridge.git && cd echo-bridge | |
| mvn install | |
| cd target | |
| rm -rf /etc/echo-bridge | |
| mkdir /etc/echo-bridge | |
| cp amazon-echo-bridge-*.jar /etc/echo-bridge | |
| chmod +x /etc/echo-bridge/* | |
| chown root.root /etc/echo-bridge/* | |
| # Start the Echo Bridge at boot. | |
| touch mycron | |
| crontab -l > mycron | |
| echo "@reboot java -jar /etc/echo-bridge/amazon-echo-bridge-*.jar" >> mycron | |
| crontab mycron | |
| rm -rf mycron | |
| printf "Done!" | |
| printf "\n\n\n\n1) Run 'codeget' then point your wireless outlet remote at your Pi and test every button.\n" | |
| printf "\n2) Record the codes you see most often for each button and write them down on a piece of paper.\n" | |
| printf "\n3) Now, run 'nano /etc/openhab/configurations/items/default.items' and add the codes you just recorded.\n" | |
| printf "\n4) When you're done, run 'startx', open Midori, navigate to http://localhost/configurator.html and add your outlets using the template below:\n" | |
| printf "\n DEVICE NAME: (whatever you want to call your device when speaking to your Echo. (e.g. Lamp, My TV, etc.)\n" | |
| printf "\n ON URL: http://localhost:8080/CMD?Outlet_Number=ON (e.g. localhost:8080/CMD?Outlet_One=ON)\n" | |
| printf "\n OFF URL: http://localhost:8080/CMD?Outlet_Number=OFF (e.g. localhost:8080/CMD?Outlet_One=OFF)\n\n\n" | |
| printf "\nYou're done! Ask your Echo to search for devices. After it's done you can say things like 'Alexa, turn on my lamp!'\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment