Procházet zdrojové kódy

Add Grafana to the template

Robert Middleswarth před 2 roky
rodič
revize
bc1d2221ec
3 změnil soubory, kde provedl 80 přidání a 0 odebrání
  1. 23 0
      stack/grafana.yml
  2. 25 0
      template/apps/grafana.json
  3. 32 0
      tools/install_grafana.sh

+ 23 - 0
stack/grafana.yml

@@ -0,0 +1,23 @@
+version: "2.4"
+services:
+  grafana:
+    container_name: grafana
+    environment:
+      - GF_USERS_ALLOW_SIGN_UP=false
+      - GF_PATHS_CONFIG=/etc/grafana/grafana.ini
+      - GF_PATHS_DATA=/var/lib/grafana
+      - GF_PATHS_HOME=/usr/share/grafana
+      - GF_PATHS_LOGS=/var/log/grafana
+      - GF_PATHS_PLUGINS=/var/lib/grafana/plugins
+      - GF_PATHS_PROVISIONING=/etc/grafana/provisioning
+    hostname: grafana
+    image: grafana/grafana:latest
+    ports:
+      - 3030:3000
+    restart: unless-stopped
+    volumes:
+      # to be modified depending on your needs
+      - /portainer/Files/AppData/Config/grafana/data:/var/lib/grafana
+      - /portainer/Files/AppData/Config/grafana/grafana.ini:/etc/grafana/grafana.ini
+      - /portainer/Files/AppData/Config/grafana/provisioning:/etc/grafana/provisioning
+

+ 25 - 0
template/apps/grafana.json

@@ -0,0 +1,25 @@
+{
+	"categories": [
+		"Monitor",
+		"Tools"
+	],
+	"description": "Grafana Dashboard anything. Observe everything.  Query, visualize, alert on, and understand your data no matter where it’s stored. With Grafana you can create, explore, and share all of your data through beautiful, flexible dashboards.",
+	"logo": "https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/images/grafana.png",
+	"name": "grafana",
+	"officialDoc": "https://grafana.com/docs/grafana/v9.0/setup-grafana/installation/docker/",
+	"platform": "linux",
+	"ports": [
+		"3030:3000/tcp"
+	],
+	"preInstallScript": "install_grafana.sh",
+	"repository": {
+		"stackfile_arm32": "stack/grafana.yml",
+		"stackfile_arm64": "stack/grafana.yml",
+		"stackfile_amd64": "stack/grafana.yml",
+		"url": "https://github.com/pi-hosted/pi-hosted"
+	},
+	"restart_policy": "unless-stopped",
+	"title": "Grafana",
+	"type": 3,
+	"webpage": "https://grafana.com/grafana/"
+}

+ 32 - 0
tools/install_grafana.sh

@@ -0,0 +1,32 @@
+#!/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/grafana/data || error "Failed to create data directory for Grafana!"
+
+echo "Download grafana.ini ..."
+if [ -d /portainer/Files/AppData/Config/grafana/grafana.ini ];
+then
+    echo "/portainer/Files/AppData/Config/grafana/grafana.ini is a directory removing"
+    rm -rf '/portainer/Files/AppData/Config/grafana/grafana.ini'
+fi
+sudo touch /portainer/Files/AppData/Config/grafana/grafana.ini || error "Failed to touch grafana.ini file!"
+echo "Setting permissions..."
+sudo chown -R 472:472 /portainer/Files/AppData/Config/grafana/data || error "Failed to set permissions for Grafana data!"
+echo "Done You are ready to goto next step in the install document"