فهرست منبع

Update to include a pre_install script to include a basic config script

Robert Middleswarth 2 سال پیش
والد
کامیت
f263f45a0e
3فایلهای تغییر یافته به همراه42 افزوده شده و 1 حذف شده
  1. 4 0
      configs/eclipse-mosquitto.json
  2. 3 1
      template/apps/eclipse-mosquitto.json
  3. 35 0
      tools/install_mosquitto.sh

+ 4 - 0
configs/eclipse-mosquitto.json

@@ -0,0 +1,4 @@
+persistence true
+persistence_location /mosquitto/data/
+log_dest file /mosquitto/log/mosquitto.log
+

+ 3 - 1
template/apps/eclipse-mosquitto.json

@@ -1,8 +1,9 @@
 {
 	"categories": [
+		"Other",
 		"Tools"
 	],
-	"description": "Eclipse Mosquitto is an open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.",
+	"description": "Eclipse Mosquitto is an open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\r\nHave a look on https://mosquitto.org/man/mosquitto_passwd-1.html",
         "image_arm32": "eclipse-mosquitto:latest",
         "image_arm64": "eclipse-mosquitto:latest",
         "image_amd64": "eclipse-mosquitto:latest",
@@ -16,6 +17,7 @@
 	],
 	"restart_policy": "unless-stopped",
 	"title": "Eclipse Mosquitto MQTT",
+	"preInstallScript": "install_mosquitto.sh",
 	"type": 1,
 	"volumes": [
 		{

+ 35 - 0
tools/install_mosquitto.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+
+function error {
+  echo -e "\\e[91m$1\\e[39m"
+  exit 1
+}
+
+function check_internet() {
+  printf "Checking if you are online..."
+  wget -q --spider http://github.com
+  if [ $? -eq 0 ]; then
+    echo "Online. Continuing."
+  else
+    error "Offline. Go connect to the internet then run the script again."
+  fi
+}
+
+check_internet
+
+echo "Creating directories..."
+sudo mkdir -p /portainer/Files/AppData/Config/eclipse-mosquitto/config || error "Failed to create config directory!"
+sudo mkdir -p /portainer/Files/AppData/Config/eclipse-mosquitto/data || error "Failed to create data directory!"
+sudo mkdir -p /portainer/Files/AppData/Config/eclipse-mosquitto/log || error "Failed to create log directory!"
+echo "Downloading Eclipse Mosquitto MQTT config files if they don't exist"
+if [ -d /portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto.conf ];
+then
+    echo "/portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto.conf is a directory removing"
+    rm -rf '/portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto.conf/'
+fi
+
+if [ ! -f /portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto.conf ]; 
+then
+	sudo wget -O /portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto.conf https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/configs/eclipse-mosquitto.conf || error "Failed to download mosquitto.conf file!"
+fi
+echo "Pre-install is complete"