Skip to content

Instantly share code, notes, and snippets.

@Landrash
Last active February 3, 2019 02:52
Show Gist options
  • Save Landrash/8afefca92bfb96c294b5501fc52f4cbc to your computer and use it in GitHub Desktop.
Save Landrash/8afefca92bfb96c294b5501fc52f4cbc to your computer and use it in GitHub Desktop.
Install script for openzwave for hassbian
#!/bin/bash
# Install by running:
# wget -Nnv https://gist.githubusercontent.com/Landrash/8afefca92bfb96c294b5501fc52f4cbc/raw/89ff001897859d70776d9b13e364a9dacc3861a9/openzwave-hassbian.sh && sudo bash openzwave-hassbian.sh
echo "Open Z-Wave Installer for Hassbian"
echo "Copyright(c) 2016 Dale Higgs <https://gitter.im/dale3h>"
echo
echo "Running apt-get preparation"
apt-get update
apt-get upgrade -y
apt-get install -y git make python3-dev libudev-dev python3-sphinx python3-setuptools libgnutlsxx28 libgnutls28-dev libssl-dev
echo "Changing to homeassistant user"
sudo -u homeassistant -H /bin/bash <<EOF
echo "Activating virtualenv"
source /srv/homeassistant/bin/activate
echo "Installing latest version of cython"
pip3 install --upgrade cython==0.24.1
echo "Creating source directory"
mkdir -p /srv/homeassistant/src
chown -R homeassistant:homeassistant /srv/homeassistant/src
echo "Cloning python-openzwave"
cd /srv/homeassistant/src
git clone --branch v0.3.1 https://github.com/OpenZWave/python-openzwave.git
echo "Building python-openzwave"
chown homeassistant:homeassistant python-openzwave
cd python-openzwave
git checkout python3
make build
make install
echo "Deactivating virtualenv"
deactivate
EOF
echo "Creating libmicrohttpd directory"
cd /srv/homeassistant/src
mkdir libmicrohttpd
chown homeassistant:homeassistant libmicrohttpd
cd /srv/homeassistant/src/libmicrohttpd
echo "Downloading libmicrohttpd-0.9.19"
wget ftp://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.19.tar.gz
chown homeassistant:homeassistant libmicrohttpd-0.9.19.tar.gz
tar zxvf libmicrohttpd-0.9.19.tar.gz
chown homeassistant:homeassistant libmicrohttpd-0.9.19
echo "Building libmicrohttpd-0.9.19"
cd libmicrohttpd-0.9.19
./configure
make
make install
echo "Cloning open-zwave-control-panel"
cd /srv/homeassistant/src
git clone https://github.com/OpenZWave/open-zwave-control-panel.git
chown -R homeassistant:homeassistant open-zwave-control-panel
echo "Building open-zwave-control-panel"
cd open-zwave-control-panel
rm Makefile
wget https://raw.githubusercontent.com/home-assistant/fabric-home-assistant/master/Makefile
chown homeassistant:homeassistant Makefile
make
echo "Linking ozwcp config directory"
ln -sd /srv/homeassistant/lib/python3.*/site-packages/libopenzwave-0.3.1-*-linux*.egg/config
chown -R homeassistant:homeassistant /srv/homeassistant/src
echo "Linking Home Assistant OpenZWave config directory"
cd /home/homeassistant/.homeassistant
sudo -u homeassistant ln -sd /srv/homeassistant/lib/python3.*/site-packages/libopenzwave-0.3.1-*-linux*.egg/config
chown -R homeassistant:homeassistant /home/homeassistant/.homeassistant
echo
echo "Done!"
echo
echo "Currently only blame @Landrash on gitter.im if this script breaks"
#echo "If you have issues with this script, please contact @dale3h on gitter.im"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment