From 97ca4a7d25cac924656e6e0abef002bd8ee7de22 Mon Sep 17 00:00:00 2001 From: 1nv1 <nelson.lombardo@gmail.com> Date: Wed, 25 Aug 2021 10:07:02 -0300 Subject: [PATCH] Added the detection of docker or podman to start the node --- start.sh | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/start.sh b/start.sh index e962766..9db7528 100755 --- a/start.sh +++ b/start.sh @@ -1,10 +1,23 @@ #!/bin/bash trap 'exit 1' ERR +flag_exit=0 +res='fail' +cmd='' -if ! which docker > /dev/null 2>&1 -then - echo 'Can not find Docker. Make sure it is installed.' >&2 +detect_cmd() +{ + if which $1 > /dev/null 2>&1; then + cmd=$1 + res='success' + fi +} + +detect_cmd 'podman' +detect_cmd 'docker' + +if [[ $res = 'fail' ]]; then + echo 'Can not find any command to create containers (podman or docker).' >&2 exit 1 fi @@ -24,14 +37,14 @@ else fi # Run this just a single time. -# Docker itself makes sure it autostarts if it crashes or the server reboots. -docker run \ - --detach \ - --restart=unless-stopped \ - --memory 4g \ - $mounts \ - -p 8545:8545 \ - -p 8546:8546 \ - -p 30303:30303 \ - --name ${name} \ - bfaar/nodo:${tag} +# Command itself makes sure it autostarts if it crashes or the server reboots. +$cmd run \ + --detach \ + --restart=unless-stopped \ + --memory 4g \ + $mounts \ + -p 8545:8545 \ + -p 8546:8546 \ + -p 30303:30303 \ + --name ${name} \ + bfaar/nodo:${tag} -- GitLab