From 7f3692740c3a2cfc9d3b916921edb087ed9d1063 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Thu, 30 Apr 2020 15:05:21 +0200 Subject: [PATCH] Initial commit. --- create.sh | 17 +++++++++++++++++ docker-compose.yml | 24 ++++++++++++++++++++++++ install.sh | 32 ++++++++++++++++++++++++++++++++ start.sh | 8 ++++++++ 4 files changed, 81 insertions(+) create mode 100755 create.sh create mode 100644 docker-compose.yml create mode 100755 install.sh create mode 100755 start.sh diff --git a/create.sh b/create.sh new file mode 100755 index 0000000..a5b350f --- /dev/null +++ b/create.sh @@ -0,0 +1,17 @@ +#!/bin/bash +#Absolute path to this script +SCRIPT=$(readlink -f $0) +#Absolute path this script is in +SCRIPTPATH=$(dirname $SCRIPT) + +cd $SCRIPTPATH + +for NETWORK in mysqlnet reverse-proxy +do + sudo docker network inspect ${NETWORK} &> /dev/null && continue + sudo docker network create ${NETWORK} + sudo docker network inspect ${NETWORK} &> /dev/null || \ + { echo "ERROR: could not create network ${NETWORK}, exiting."; exit 1; } +done + +sudo -E bash -c 'docker-compose up --no-start' diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4e6ede5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "2.1" + +services: + + grafana: + container_name: grafana + image: grafana/grafana + networks: + - reverse-proxy + - mysqlnet + expose: + - "3000/tcp" + volumes: + - /mnt/volumes/var_lib_grafana/data:/var/lib/grafana:Z + - /mnt/volumes/etc_grafana/data:/etc/grafana:Z + - /mnt/volumes/var_log_grafana/data:/var/log/grafana:Z + +networks: + + reverse-proxy: + external: true + + mysqlnet: + external: true diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..66a5902 --- /dev/null +++ b/install.sh @@ -0,0 +1,32 @@ +#!/bin/bash +#Absolute path to this script +SCRIPT=$(readlink -f $0) +#Absolute path this script is in +SCRIPTPATH=$(dirname $SCRIPT) +STACK=$(basename "$SCRIPTPATH") + +mkdir -p /mnt/volumes/var_lib_grafana/data +chown -R 472:472 /mnt/volumes/var_lib_grafana/data +mkdir -p /mnt/volumes/etc_grafana/data +chown -R root:root /mnt/volumes/etc_grafana/data +chmod -R a+r /mnt/volumes/etc_grafana/data +mkdir -p /mnt/volumes/var_log_grafana/data +chown -R 472:472 /mnt/volumes/var_log_grafana/data + +cat << EOF > /etc/systemd/system/${STACK}.service +[Unit] +Description=Starting ${STACK} +After=network-online.target firewalld.service docker.service docker.socket +Wants=network-online.target docker.service +Requires=docker.socket + +[Service] +Type=oneshot +User=$SUDO_USER +ExecStart=$SCRIPTPATH/start.sh + +[Install] +WantedBy=multi-user.target +EOF +systemctl daemon-reload +systemctl enable ${STACK}.service diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..1f4bfdf --- /dev/null +++ b/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash +#Absolute path to this script +SCRIPT=$(readlink -f $0) +#Absolute path this script is in +SCRIPTPATH=$(dirname $SCRIPT) + +cd $SCRIPTPATH +sudo docker-compose start