From 960d1143e149277959bbc7319e0276b1583b7ed7 Mon Sep 17 00:00:00 2001 From: mate-dev <67105053+mate-dev@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:56:01 +0000 Subject: [PATCH] Create docker checker and installer --- app/Dockerfile | 1 + mmrelay.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 mmrelay.sh diff --git a/app/Dockerfile b/app/Dockerfile index c053552..a654ede 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -2,6 +2,7 @@ FROM python:3.11-slim-bookworm AS app LABEL "website"="https://github.com/mate-dev/mmrelaynode" RUN groupadd -g 1000 mesh && useradd -ml -u 1000 -g 1000 -s /bin/bash mesh RUN pip install --upgrade pip -qq +RUN ln -s /home/mesh/.local/bin/meshtastic /bin/meshtastic USER mesh COPY --chown=mesh:mesh meshtastic-matrix-relay /home/mesh/app WORKDIR /home/mesh/app diff --git a/mmrelay.sh b/mmrelay.sh new file mode 100644 index 0000000..629655d --- /dev/null +++ b/mmrelay.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e + +#Check linux distro +OS=$(uname -s | tr A-Z a-z) +source /etc/os-release +case $ID in + debian|ubuntu|mint) + RUN="apt-get" + ;; + fedora|rhel|centos) + RUN="yum" + ;; + *) + echo -n "unsupported linux distro" + ;; +esac +# Check and install docker and git +if ! docker &> /dev/null; then + echo "Docker is not installed. Installing it via the script from docker.com" + echo "================================================================" + sudo $RUN update &> /dev/null && sudo $RUN install -y curl &> /dev/null && sudo $RUN install -y git &> /dev/null + sudo groupadd docker > /dev/null 2>&1 || true + sudo usermod -aG docker $USER + curl -fsSL https://get.docker.com -o get-docker.sh + chmod +x get-docker.sh + sh -c ./get-docker.sh + rm get-docker.sh +fi + +# Sprawdzamy, czy docker działa poprzez listowanie kontenerów +if ! docker ps | grep -q "CONTAINER"; then + echo "================================================================================" + echo "If you see this error, type 'newgrp docker' and check if 'docker ps' returns an error." + echo "Or log out and log in for the changes to take effect." + echo "After this re-enable the script." + exit 1 +fi + +# Pozostała część skryptu +echo "jedziemy" +#docker compose -f "docker-compose.yaml" up -d --build