Skip to content

Commit

Permalink
added rtl_433 and docker bash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
gcgarner committed Nov 17, 2019
1 parent 626fa53 commit 124e3cc
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alias iotstack_up="docker-compose -f ~/IOTstack/docker-compose.yml up -d"
alias iotstack_down="docker-compose -f ~/IOTstack/docker-compose.yml down"
alias iotstack_start="docker-compose -f ~/IOTstack/docker-compose.yml start"
alias iotstack_stop="docker-compose -f ~/IOTstack/docker-compose.yml stop"
alias iotstack_update="docker-compose -f ~/IOTstack/docker-compose.yml pull"
alias iotstack_build="docker-compose -f ~/IOTstack/docker-compose.yml build"

25 changes: 25 additions & 0 deletions .native/rtl_433.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
sudo touch /etc/modprobe.d/blacklist-rtl.conf
[ $(grep -c rtl28xxu /etc/modprobe.d/blacklist-rtl.conf) -eq 0 ] && sudo echo "blacklist dvb_usb_rtl28xxu" >>/etc/modprobe.d/blacklist-rtl.conf

sudo touch /etc/modprobe.d/blacklist-rtl8xxxu.conf
[ $(grep -c rtl8xxxu /etc/modprobe.d/blacklist-rtl8xxxu.conf) -eq 0 ] && sudo echo "blacklist rtl8xxxu" >>/etc/modprobe.d/blacklist-rtl8xxxu.conf

sudo apt-get update
sudo apt-get install -y libtool \
libusb-1.0.0-dev \
librtlsdr-dev \
rtl-sdr \
doxygen \
cmake \
automake

git clone https://github.com/merbanan/rtl_433.git ~/rtl_433
cd ~/rtl_433/
mkdir build
cd build
cmake ../
make
sudo make install

echo "you should reboot for changes to take effect"
9 changes: 8 additions & 1 deletion .templates/grafana/grafana.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
#TZ=Africa/Johannesburg
GF_PATHS_DATA=/var/lib/grafana
GF_PATHS_LOGS=/var/log/grafana
GF_PATHS_LOGS=/var/log/grafana
# [SERVER]
#GF_SERVER_ROOT_URL=http://localhost:3000/grafana
#GF_SERVER_SERVE_FROM_SUB_PATH=true
# [SECURITY]
#GF_SECURITY_ADMIN_USER=admin
#GF_SECURITY_ADMIN_PASSWORD=admin
3 changes: 2 additions & 1 deletion .templates/mosquitto/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
- 1883:1883
- 9001:9001
volumes:
- ./volumes/mosquitto/:/mosquitto/
- ./volumes/mosquitto/data:/mosquitto/data
- ./volumes/mosquitto/log:/mosquitto/log
- ./services/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
15 changes: 14 additions & 1 deletion .templates/pihole/pihole.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#TZ=America/Chicago
WEBPASSWORD=pihole

#DNS1=8.8.8.8
#DNS2=8.8.4.4
#DNSSEC=false
#DNS_BOGUS_PRIV=True
#CONDITIONAL_FORWARDING=False
#CONDITIONAL_FORWARDING_IP=your_router_ip_here (only if CONDITIONAL_FORWARDING=ture)
#CONDITIONAL_FORWARDING_DOMAIN=optional
#CONDITIONAL_FORWARDING_REVERSE=optional
#ServerIP=your_Pi's_IP_here << recommended
#ServerIPv6= your_Pi's_ipv6_here << Required if using ipv6
#VIRTUAL_HOST=$ServerIP
#IPv6=True
INTERFACE=eth0
#DNSMASQ_LISTENING=local
18 changes: 18 additions & 0 deletions .templates/rtl_433/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:buster-slim

ENV MQTT_ADDRESS mosquitto
ENV MQTT_PORT 1883
ENV MQTT_USER ""
ENV MQTT_PASSWORD ""
ENV MQTT_TOPIC RTL_433

RUN apt-get update && apt-get install -y git libtool libusb-1.0.0-dev librtlsdr-dev rtl-sdr cmake automake && \
git clone https://github.com/merbanan/rtl_433.git /tmp/rtl_433 && \
cd /tmp/rtl_433/ && \
mkdir build && \
cd build && \
cmake ../ && \
make && \
make install

CMD ["sh", "-c", "rtl_433 -F mqtt://${MQTT_ADDRESS}:${MQTT_PORT},events=${MQTT_TOPIC},user=${MQTT_USER},pass=${MQTT_PASSWORD}"]
6 changes: 6 additions & 0 deletions .templates/rtl_433/rtl_433.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TZ=Africa/Johannesburg
MQTT_ADDRESS=mosquitto
MQTT_PORT=1883
#MQTT_USER=""
#MQTT_PASSWORD=""
MQTT_TOPIC=RTL_433
8 changes: 8 additions & 0 deletions .templates/rtl_433/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rtl_433:
container_name: rtl_433
build: ./services/rtl_433/.
env_file:
- ./services/rtl_433/rtl_433.env
devices:
- /dev/bus/usb
restart: unless-stopped
57 changes: 46 additions & 11 deletions menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ timezones() {
TZ=$(cat /etc/timezone)

#test for TZ=
[ $(grep "TZ=" $env_file) ] && sed -i "/TZ=/c\TZ=$TZ" $env_file
[ $(grep -c "TZ=" $env_file) -ne 0 ] && sed -i "/TZ=/c\TZ=$TZ" $env_file

}

Expand Down Expand Up @@ -85,9 +85,11 @@ mainmenu_selection=$(whiptail --title "Main Menu" --menu --notags \
"install" "Install Docker" \
"build" "Build Stack" \
"hassio" "Install Hass.io (Requires Docker)" \
"native" "Native Installs" \
"commands" "Docker commands" \
"backup" "Backup options" \
"misc" "Miscellaneous commands" \
"update" "Update IOTstack" \
3>&1 1>&2 2>&3)

case $mainmenu_selection in
Expand Down Expand Up @@ -131,6 +133,7 @@ case $mainmenu_selection in
"pihole" "Pi-Hole" "OFF" \
"plex" "Plex media server" "OFF" \
"tasmoadmin" "TasmoAdmin" "OFF" \
"rtl_433" "RTL_433 to mqtt" "OFF" \
3>&1 1>&2 2>&3)

mapfile -t containers <<<"$container_selection"
Expand All @@ -157,16 +160,19 @@ case $mainmenu_selection in
#MAINMENU Docker commands -----------------------------------------------------------
"commands")

docker_selection=$(whiptail --title "Docker commands" --menu --notags \
"Shortcut to common docker commands" 20 78 12 -- \
"start" "Start stack" \
"restart" "Restart stack" \
"stop" "Stop stack" \
"stop_all" "Stop any running container regardless of stack" \
"pull" "Update all containers" \
"prune_volumes" "Delete all stopped containers and docker volumes" \
"prune_images" "Delete all images not associated with container" \
3>&1 1>&2 2>&3)
docker_selection=$(
whiptail --title "Docker commands" --menu --notags \
"Shortcut to common docker commands" 20 78 12 -- \
"aliases" "Add iotstack_up and iotstack_down aliases" \
"start" "Start stack" \
"restart" "Restart stack" \
"stop" "Stop stack" \
"stop_all" "Stop any running container regardless of stack" \
"pull" "Update all containers" \
"prune_volumes" "Delete all stopped containers and docker volumes" \
"prune_images" "Delete all images not associated with container" \
3>&1 1>&2 2>&3
)

case $docker_selection in
"start") ./scripts/start.sh ;;
Expand All @@ -176,6 +182,16 @@ case $mainmenu_selection in
"pull") ./scripts/update.sh ;;
"prune_volumes") ./scripts/prune-volumes.sh ;;
"prune_images") ./scripts/prune-images.sh ;;
"aliases")
touch ~/.bash_aliases
if [ $(grep -c 'IOTstack' ~/.bash_aliases) -eq 0 ]; then
echo ". ~/IOTstack/.bash_aliases" >>~/.bash_aliases
echo "added aliases"
else
echo "aliases already added"
fi
source ~/.bashrc
;;
esac
;;
#Backup menu ---------------------------------------------------------------------
Expand Down Expand Up @@ -266,6 +282,25 @@ case $mainmenu_selection in
exit
fi
;;
"update")
echo "Pulling latest project file from Github.com ---------------------------------------------"
git pull origin master
echo "git status ------------------------------------------------------------------------------"
git status
;;
"native")

native_selections=$(whiptail --title "Native installs" --menu --notags \
"Install local applications" 20 78 12 -- \
"rtl_433" "RTL_433" \
3>&1 1>&2 2>&3)

case $native_selections in
"rtl_433")
bash ./.native/rtl_433.sh
;;
esac
;;
*) ;;

esac

0 comments on commit 124e3cc

Please sign in to comment.