mqtt-install.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies"
  14. $STD apt-get install -y curl
  15. $STD apt-get install -y sudo
  16. $STD apt-get install -y mc
  17. msg_ok "Installed Dependencies"
  18. msg_info "Installing Mosquitto MQTT Broker"
  19. if [ "$PCT_OSTYPE" == "debian" ]; then
  20. VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
  21. wget -qO- http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key >/etc/apt/trusted.gpg.d/mosquitto-repo.asc
  22. wget -qO /etc/apt/sources.list.d/mosquitto-${VERSION}.list http://repo.mosquitto.org/debian/mosquitto-${VERSION}.list
  23. $STD apt-get update
  24. fi
  25. $STD apt-get -y install mosquitto
  26. $STD apt-get -y install mosquitto-clients
  27. cat <<EOF >/etc/mosquitto/conf.d/default.conf
  28. allow_anonymous false
  29. persistence true
  30. password_file /etc/mosquitto/passwd
  31. listener 1883
  32. EOF
  33. msg_ok "Installed Mosquitto MQTT Broker"
  34. motd_ssh
  35. customize
  36. msg_info "Cleaning up"
  37. $STD apt-get autoremove
  38. $STD apt-get autoclean
  39. msg_ok "Cleaned"