diff --git a/README.md b/README.md index fa8af4b..80cae18 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,11 @@ then you have to create `.env` file. Convert it from `template.env` file: ```commandline mv template.env .env ``` -After that, open the file and insert libp2p RELAY_ADDRESS. +After that,You may open the file and edit default values such as: +- Versions of packages +- path to repository where will be stored all configurations folders. +- time zone in ["tz database name"](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). -Optionally, you can provide path to repository where will be stored all configurations folders. -Also, you can provide your time zone in ["tz database name"](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). ## Installation and Run @@ -39,6 +40,9 @@ Run bash script: ```commandline bash setup.sh ``` + +After everything started, Home Assistant web interface will be on 8123 port and zigbee2mqtt on 8099 port. + ## Stop To stop everything use next command: diff --git a/compose.yaml b/compose.yaml index fd2c38e..7712790 100644 --- a/compose.yaml +++ b/compose.yaml @@ -19,6 +19,7 @@ services: zigbee2mqtt: container_name: zigbee2mqtt image: koenkk/zigbee2mqtt:${Z2M_VERSION} + profiles: [z2m] restart: unless-stopped volumes: - ${CONFIG_PATH}/zigbee2mqtt/data:/app/data @@ -50,8 +51,7 @@ services: libp2p: container_name: libp2p-proxy restart: unless-stopped - build: - context: ${CONFIG_PATH}/libp2p-ws-proxy/. + image: ghcr.io/pinoutltd/libp2p-ws-proxy:latest ports: - 127.0.0.1:8888:8888 - 127.0.0.1:9999:9999 diff --git a/scripts/mosquitto.conf b/scripts/mosquitto.conf new file mode 100644 index 0000000..163d387 --- /dev/null +++ b/scripts/mosquitto.conf @@ -0,0 +1,3 @@ +listener 1883 +allow_anonymous false +password_file /mosquitto/passwd \ No newline at end of file diff --git a/setup.sh b/setup.sh index 37d07f5..cbdf00e 100644 --- a/setup.sh +++ b/setup.sh @@ -2,7 +2,7 @@ echo "this script will create all necessary repositories and start docker containers" - +Z2MENABLE=true # First we need to check that user insert the zigbee stick if [ -d /dev/serial/by-id/ ]; then @@ -11,16 +11,61 @@ if [ -d /dev/serial/by-id/ ]; then echo "the zigbee coordinator is installed" else echo "Cannot find zigbee coordinator location. Please insert it and run script again." - exit + echo "Do you want to continue without zigbee coordinator? It will not start Zigbee2MQTT container." + while true; do + read -p "Do you want to proceed? (y/n) " yn + case $yn in + [yY] ) echo ok, we will proceed; + Z2MENABLE=false + break;; + [nN] ) echo exiting...; + exit;; + * ) echo invalid response;; + esac + done fi else echo "Cannot find zigbee coordinator location. Please insert it and run script again. The directory "/dev/serial/by-id/" does not exist" - exit + echo "Do you want to continue without zigbee coordinator? It will not start Zigbee2MQTT container." + while true; do + read -p "Do you want to proceed? (y/n) " yn + case $yn in + [yY] ) echo ok, we will proceed; + Z2MENABLE=false + break;; + [nN] ) echo exiting...; + exit;; + * ) echo invalid response;; + esac + done +fi + +# count how many devices connected +NUMB=$(ls -1q /dev/serial/by-id/ | wc -l) + +if (($NUMB > 1)); then + echo "You have more that 1 connected devices. Please choose one" + select f in /dev/serial/by-id/*; do + test -n "$f" && break + echo ">>> Invalid Selection" + done + echo "You select $f" + Z2MPATH=$f +else + Z2MPATH=$(ls /dev/serial/by-id/) + Z2MPATH="/dev/serial/by-id/"$Z2MPATH fi -Z2MPATH=$(ls /dev/serial/by-id/) -Z2MPATH="/dev/serial/by-id/"$Z2MPATH + export Z2MPATH +echo "Checking docker installation" +if command -v docker &> /dev/null; then + echo "Docker installation found" +else + echo "Docker installation not found. Please install docker." + exit 1 +fi + # check if user in docker group if id -nG "$USER" | grep -qw "docker"; then echo "$USER belongs to docker group" @@ -29,6 +74,15 @@ else exit 1 fi +# check .env file +if [[ -f .env ]] +then + echo ". env file exists" +else + echo ".env file does not exist. Exit" + exit 1 +fi + # grap variables from .env file excluding comments export $(grep -v '^#' .env | xargs) @@ -73,9 +127,7 @@ else MOSQUITTO_PASSWORD=$(openssl rand -hex 10) export MOSQUITTO_PASSWORD - echo "listener 1883 - allow_anonymous false - password_file /mosquitto/passwd" | tee ./mosquitto/config/mosquitto.conf + cp $CURRENT_PATH/scripts/mosquitto.conf ./mosquitto/config/mosquitto.conf #zigbee2mqtt echo "# Home Assistant integration (MQTT discovery) @@ -164,18 +216,14 @@ else rm $ROBONOMICS_VERSION.zip fi -if [[ -d ./libp2p-ws-proxy ]] -then - echo "libp2p-ws-proxy directory already exist" -else - #libp2p - git clone https://github.com/PinoutLTD/libp2p-ws-proxy.git - echo "PEER_ID_CONFIG_PATH="peerIdJson.json" - RELAY_ADDRESS="$RELAY_ADDRESS" - SAVED_DATA_DIR_PATH="saved_data" - " > libp2p-ws-proxy/.env -fi - # return to the directory with compose cd $CURRENT_PATH -docker compose up -d \ No newline at end of file + + +if [ "$Z2MENABLE" = "true" ]; then + echo "start docker with zigbee2mqtt" + docker compose --profile z2m up -d +else + echo "start docker without zigbee2mqtt" + docker compose up -d +fi diff --git a/template.env b/template.env index 38cc665..b09e837 100644 --- a/template.env +++ b/template.env @@ -1,7 +1,3 @@ -# Provide Relay address for libp2p proxy -RELAY_ADDRESS= - -#Optional: # provide the path to the repository where docker will store all configuration CONFIG_PATH=. # provide your time zone in tz database name, like TZ=America/Los_Angeles @@ -11,7 +7,7 @@ ZIGBEE_CHANNEL=11 #Provide version of docker images MOSQUITTO_VERSION=2.0.18 -Z2M_VERSION=1.36.1 -HA_VERSION=2024.4.0 -ROBONOMICS_VERSION=1.8.2 +Z2M_VERSION=1.37.1 +HA_VERSION=2024.5.4 +ROBONOMICS_VERSION=1.8.3 IPFS_VERSION=0.27.0 \ No newline at end of file