Skip to content

Commit a34b2c9

Browse files
authored
Merge pull request #1137 from ct-Open-Source/development
Release v2.4.6
2 parents 61ba060 + f2e9942 commit a34b2c9

17 files changed

+127
-57
lines changed

.env-template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Attention: "host" means your computer where you are running docker on
2+
3+
WLAN=wlan0 #must match the name of your wlan-interface on your host, you may find it with ifconfig
4+
AP=vtrust-flash #the name of the created AP, can be anything you want
5+
GATEWAY=10.42.42.1 #gateway address, leave it here
6+
LOCALBACKUPDIR=./data/backups #location on your host where you want to store backuos of the old firmware & logs

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ node_modules/
109109
device-info.txt
110110
scripts/smartconfig/package-lock.json
111111

112-
# firmware backups directory
112+
# firmware backups directory and data-file
113113
backups/
114+
data
114115

115116
# flag files
116117
eula_accepted

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM phusion/baseimage:master
1+
FROM alpine:3.13
22

3-
RUN apt-get update && apt-get install -y sudo iproute2 iputils-ping
3+
RUN apk add --update bash git iw dnsmasq hostapd screen curl py3-pip py3-wheel python3-dev mosquitto haveged net-tools openssl openssl-dev gcc musl-dev linux-headers sudo coreutils grep iproute2 ncurses
44

5-
RUN echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
5+
RUN python3 -m pip install --upgrade paho-mqtt tornado git+https://github.com/drbild/sslpsk.git pycryptodomex
66

77
COPY docker/bin /usr/bin/
88

99
COPY . /usr/bin/tuya-convert
1010

11-
RUN cd /usr/bin/tuya-convert && ./install_prereq.sh
11+
WORKDIR "/usr/bin/tuya-convert"
1212

13-
RUN mkdir -p /etc/service/tuya && cd /etc/service/tuya && ln -s /usr/bin/config.sh run
13+
ENTRYPOINT ["tuya-start"]

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ These scripts were tested in
3434
* a Raspberry Pi 3B / 3B+ Raspberry Pi OS Buster (previously called Raspbian) and its internal Wifi chip
3535
* a Raspberry Pi 3B+ + USB-WIFI with an image from [here](https://www.offensive-security.com/kali-linux-arm-images/)
3636
* Ubuntu 18.04.3 64Bit in VirtualBox on Win10 with a cheap RTL8188CU Wifi Adapter connected to the VM
37+
* Ubuntu Mate 18.04.5 32bit in VirtualBox on Win 10 with cheap Ralink 802.11n WLAN (MediaTek RT5370) WiFi Adapter connected to VM
3738

3839
Any Linux with a Wifi adapter which can act as an Access Point should also work. Please note that we have tested the Raspberry Pi with clean installations only. If you use your Raspberry Pi for anything else, we recommend using another SD card with a clean installation.
3940

@@ -83,26 +84,24 @@ Requirements:
8384
* docker is installed
8485
* docker-compose is installed
8586

86-
Create docker image:
87+
Preparations:
8788
* git clone https://github.com/ct-Open-Source/tuya-convert
8889
* cd tuya-convert
89-
* docker build -t tuya:latest .
90-
91-
Setup docker-compose:
92-
* copy docker/docker-compose.sample.yml to a new folder you created, the file should be named docker-compose.yml
93-
* you may adjust this docker-compose.yml, if necessary:
94-
* environment-variables may be different, for example network-adapter may be different from wlan0
95-
* adjust the volume folder, where you want your backups stored
96-
97-
Run the image:
98-
* go into the folder you copied docker-compose.yml
99-
* docker-compose up -d
100-
* docker-compose exec tuya start
101-
* tuya-convert now starts within docker
102-
103-
Stop the image:
104-
* docker-compose exec tuya stop
105-
* docker-compose down
90+
* if you have already cloned this repo just cd into the directory and execute `git pull`
91+
* cp .env-template .env
92+
* adjust the created .env-file, it contains usage information as comments
93+
94+
Building and running your container:
95+
* `docker-compose build && docker-compose run --rm tuya`
96+
* This directly starts into tuya. If you press ctrl+break or exit tuya after flashing, your container is closed and deleted
97+
98+
Troubleshooting:
99+
* Q: Where are my logs after flashing? A: The folder can be adjusted in .env with LOCALBACKUPDIR, the path here may be relative or absolute
100+
* Q: I don't want that my container is deleted after running tuya, I need this for troubleshooting! How do I accomplish this? A: Just remove --rm from `docker-compose run --rm tuya`
101+
* Q: I want to start the container, but instead of starting tuya immediately I want to get into bash. Is this possible? A: Yes just start the container with `docker-compose run --entrypoint bash tuya`.
102+
* Q: I want to rebuild my docker-image, even if there are no changes. Is this possible? A: Just start `docker-compose build --no-cache` instead of `docker-compose build`! Don't do this all the time, this is a time consuming process ...
103+
* Q: I can't connect to my USB, PCI, ... network card. How do I get this working? A: You may have an error in your .env-File. The WLAN-variable should reflect the name of your network interface on your host. Execute ifconfig and look through your interfaces.
104+
* Q: I can't get an IP-address and or connection on my phone, what's the problem? A: You may look into smarthack-wifi.log (location is set in .env with LOCALBACKUPDIR) or possible stop your firewall (e.g. NixOS seems to have a problem here). It may be a problem with a wrongly set network interface (see previous question)
106105

107106
## CONTRIBUTING
108107

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3'
2+
services:
3+
tuya:
4+
build: .
5+
privileged: true
6+
network_mode: "host"
7+
environment:
8+
WLAN: ${WLAN}
9+
AP: ${AP}
10+
GATEWAY: ${GATEWAY}
11+
volumes:
12+
- $LOCALBACKUPDIR:/usr/bin/tuya-convert/backups
File renamed without changes.

docker/bin/stop

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
cd /usr/bin/tuya-convert
2+
config-tuya.sh
33
./start_flash.sh

docker/docker-compose.sample.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

install_prereq.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
set -e
4+
debianInstall() {
5+
sudo apt-get update
6+
sudo apt-get install -y git iw dnsmasq rfkill hostapd screen curl build-essential python3-pip python3-setuptools python3-wheel python3-dev mosquitto haveged net-tools libssl-dev iproute2 iputils-ping
7+
sudo python3 -m pip install --user --upgrade paho-mqtt tornado git+https://github.com/drbild/sslpsk.git pycryptodomex
8+
}
49

5-
sudo apt-get update
6-
sudo apt-get install -y git iw dnsmasq rfkill hostapd screen curl build-essential python3-pip python3-setuptools python3-wheel python3-dev mosquitto haveged net-tools libssl-dev
10+
archInstall() {
11+
sudo pacman -S --needed git iw dnsmasq hostapd screen curl python-pip python-wheel python-pycryptodomex python-paho-mqtt python-tornado mosquitto haveged net-tools openssl
12+
sudo python -m pip install --user --upgrade git+https://github.com/drbild/sslpsk.git
13+
}
714

8-
sudo -H python3 -m pip install --upgrade paho-mqtt tornado git+https://github.com/drbild/sslpsk.git pycryptodomex
15+
if [[ -e /etc/os-release ]]; then
16+
source /etc/os-release
17+
else
18+
echo "/etc/os-release not found! Assuming debian-based system, but this will likely fail!"
19+
ID=debian
20+
fi
21+
22+
if [[ ${ID} == 'debian' ]] || [[ ${ID_LIKE-} == 'debian' ]]; then
23+
debianInstall
24+
elif [[ ${ID} == 'arch' ]] || [[ ${ID_LIKE-} == 'arch' ]]; then
25+
archInstall
26+
else
27+
if [[ -n ${ID_LIKE-} ]]; then
28+
printID="${ID}/${ID_LIKE}"
29+
else
30+
printID="${ID}"
31+
fi
32+
echo "/etc/os-release found but distribution ${printID} is not explicitly supported. Assuming debian-based system, but this will likely fail!"
33+
debianInstall
34+
fi
935

1036
echo "Ready to start upgrade"

0 commit comments

Comments
 (0)