Skip to content

Commit

Permalink
Merge pull request #1 from nakata5321/main
Browse files Browse the repository at this point in the history
release 0.0.1
  • Loading branch information
nakata5321 authored May 21, 2024
2 parents e959dfc + 7ca6a88 commit 451cc9d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 33 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions scripts/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
listener 1883
allow_anonymous false
password_file /mosquitto/passwd
90 changes: 69 additions & 21 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


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
10 changes: 3 additions & 7 deletions template.env
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 451cc9d

Please sign in to comment.