Skip to content

Instantly share code, notes, and snippets.

@Landrash
Created January 24, 2019 22:43
Show Gist options
  • Save Landrash/16424dab2a98f24eda43b93c69eb4c38 to your computer and use it in GitHub Desktop.
Save Landrash/16424dab2a98f24eda43b93c69eb4c38 to your computer and use it in GitHub Desktop.
Setup for development version of Zigbee2mqtt
#!/bin/bash
function zigbee2mqttdev-show-short-info {
echo "Setup for development version of Zigbee2mqtt."
}
function zigbee2mqttdev-show-long-info {
echo "This script installs the development version of Zigbee2mqtt."
}
function zigbee2mqttdev-show-copyright-info {
echo "Original concept by Twooter <https://github.com/landrash>."
}
function zigbee2mqttdev-install-package {
echo -n "Installing dependencies : "
node=$(which npm)
if [ -z "${node}" ]; then #Installing NodeJS if not already installed.
printf "Downloading and installing NodeJS...\\n"
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt install -y nodejs
fi
echo "Cloning dev branch of Zigbee2mqtt git repository"
git clone --single-branch --branch dev https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqttdev
chown -R pi:pi /opt/zigbee2mqttdev
echo "Running install. This might take a while and can produce som expected errors"
cd /opt/zigbee2mqttdev || exit
su pi -c "npm install"
echo "Creating service file zigbee2mqtt.service"
service_path="/etc/systemd/system/zigbee2mqttdev.service"
echo "[Unit]
Description=zigbee2mqttdev
After=network.target
[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/opt/zigbee2mqttdev
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target" > $service_path
echo "Checking the installation..."
if [ ! -f /opt/zigbee2mqttdev/data/configuration.yaml ]; then
validation=""
else
validation="ok"
fi
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo -e "Update of configuration.yaml is required found at /opt/zigbee2mqttdev/data/"
echo -e "Some further configuration is required and details can be found here https://github.com/Koenkk/zigbee2mqtt/wiki/Running-the-bridge "
echo
echo -e "Service can be started after configuration by running sudo systemctl start zigbee2mqttdev"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
}
[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment