Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update install_openzwave.sh #1

Open
wants to merge 1 commit into
base: penright-patch-1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 40 additions & 33 deletions package/opt/hassbian/suites/install_openzwave.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
#!/bin/bash

function openzwave-show-short-info {
echo "Open Z-Wave Installer for Hassbian"
}

function openzwave-show-long-info {
echo "Installs the Open Z-wave package and OZWCP for setting up your zwave network"
}

function openzwave-show-copyright-info {
echo "Copyright(c) 2016 Dale Higgs <https://gitter.im/dale3h>"
echo "Modified by Landrash for use with Hassbian."
}

function openzwave-install-package {
openzwave-show-short-info
openzwave-show-copyright-info

echo
echo
echo "Open Z-Wave Installer for Hassbian"
echo "Modified by Landrash for use with Hassbian."
echo "Remodified by unt1tled for use with Linear NGDZ00-4 (barrier_operator)."
echo "Remodified by Paul, for Hassbian .48.1 7/18/2017"
echo "Copyright(c) 2016 Dale Higgs <https://gitter.im/dale3h>"
echo

if [ "$(id -u)" != "0" ]; then
echo "This script must be run with sudo. Use \"sudo ${0} ${*}\"" 1>&2
return 1
exit 1
fi

echo "Running apt-get preparation"
Expand All @@ -31,29 +19,52 @@ apt-get upgrade -y
apt-get install -y 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
sudo -u homeassistant -H /bin/bash

echo "Activating virtualenv"
#################
#PE Update from
#source /srv/homeassistant/homeassistant_venv/bin/activate
# to
source /srv/homeassistant/bin/activate
#################

echo "Installing latest version of cython"
### Currently locked to this version since build fails for later versions.
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 https://github.com/OpenZWave/python-openzwave.git

echo "Building python-openzwave"
chown homeassistant:homeassistant python-openzwave
cd python-openzwave

echo "Cloning openzwave"
git checkout python3
rm -rf openzwave
git clone git://github.com/OpenZWave/open-zwave.git openzwave
cd openzwave

echo "Changing to openzwave Dev branch to add barrier_operator support"
git checkout Dev
cd ..

echo "Building python-openzwave with barrier_operator support\nStage 1..."
make build
make install

# Remove the 1.4 non-dev branched compile and replace with the 1.5 dev branch compiled version
rm -Rf openzwave-git/open-zwave-master/
cp -R openzwave/ openzwave-git/
mv openzwave-git/openzwave/ openzwave-git/open-zwave-master/
echo "Building stage 2..."
make install

echo "Deactivating virtualenv"
deactivate
EOF
Expand All @@ -80,21 +91,25 @@ 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
cd open-zwave-control-panel

echo "Replacing open-zwave-control-panel source files with barrier_operator support"
#wget -O zwavelib.cpp https://raw.githubusercontent.com/legrego/open-zwave-control-panel/0925251a566a36543e0c6b5cb0b2c1498bddfa68/zwavelib.cpp


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"
sudo ln -s /srv/homeassistant/lib/python3.*/site-packages/python_openzwave/ozw_config config
ln -sd /srv/homeassistant/lib/python3.*/site-packages/libopenzwave-0.*-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/python_openzwave/ozw_config
sudo -u homeassistant ln -sd /srv/homeassistant/lib/python3.*/site-packages/libopenzwave-*-linux*.egg/config
chown -R homeassistant:homeassistant /home/homeassistant/.homeassistant

echo
Expand All @@ -103,12 +118,4 @@ echo
echo "If you have issues with this script, please contact @Landrash on gitter.im"
echo "Original script by @dale3h on gitter.im"
echo
echo "To continue have a look at https://home-assistant.io/components/zwave/"
echo
echo "It's recomended that you set the optional config parameter for zwave."
echo "to config_path: ozw_config ."
echo
return 0
}

[[ $_ == $0 ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config install instead"