diff --git a/.bash_aliases b/.bash_aliases new file mode 100644 index 00000000..a8d1d767 --- /dev/null +++ b/.bash_aliases @@ -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" + diff --git a/.native/rtl_433.sh b/.native/rtl_433.sh new file mode 100755 index 00000000..5e42a6d7 --- /dev/null +++ b/.native/rtl_433.sh @@ -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" \ No newline at end of file diff --git a/.templates/grafana/grafana.env b/.templates/grafana/grafana.env index 3b8110e3..e76f26be 100644 --- a/.templates/grafana/grafana.env +++ b/.templates/grafana/grafana.env @@ -1,2 +1,9 @@ +#TZ=Africa/Johannesburg GF_PATHS_DATA=/var/lib/grafana -GF_PATHS_LOGS=/var/log/grafana \ No newline at end of file +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 diff --git a/.templates/mosquitto/service.yml b/.templates/mosquitto/service.yml index 58e3b791..e2a72159 100644 --- a/.templates/mosquitto/service.yml +++ b/.templates/mosquitto/service.yml @@ -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 diff --git a/.templates/pihole/pihole.env b/.templates/pihole/pihole.env index b7c58b53..2f768070 100644 --- a/.templates/pihole/pihole.env +++ b/.templates/pihole/pihole.env @@ -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 \ No newline at end of file diff --git a/.templates/rtl_433/Dockerfile b/.templates/rtl_433/Dockerfile new file mode 100644 index 00000000..8feebfec --- /dev/null +++ b/.templates/rtl_433/Dockerfile @@ -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}"] diff --git a/.templates/rtl_433/rtl_433.env b/.templates/rtl_433/rtl_433.env new file mode 100644 index 00000000..0f9a66d7 --- /dev/null +++ b/.templates/rtl_433/rtl_433.env @@ -0,0 +1,6 @@ +TZ=Africa/Johannesburg +MQTT_ADDRESS=mosquitto +MQTT_PORT=1883 +#MQTT_USER="" +#MQTT_PASSWORD="" +MQTT_TOPIC=RTL_433 \ No newline at end of file diff --git a/.templates/rtl_433/service.yml b/.templates/rtl_433/service.yml new file mode 100644 index 00000000..a6700638 --- /dev/null +++ b/.templates/rtl_433/service.yml @@ -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 \ No newline at end of file diff --git a/menu.sh b/menu.sh index 656bb8a7..c19b59e6 100755 --- a/menu.sh +++ b/menu.sh @@ -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 } @@ -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 @@ -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" @@ -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 ;; @@ -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 --------------------------------------------------------------------- @@ -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