Skip to content
Snippets Groups Projects
start.sh 1001 B
Newer Older
Robert Martin-Legene's avatar
Robert Martin-Legene committed
#!/bin/bash

trap 'exit 1' ERR
flag_exit=0
res='fail'
cmd=''
Robert Martin-Legene's avatar
Robert Martin-Legene committed

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
Robert Martin-Legene's avatar
Robert Martin-Legene committed
    exit 1
fi

if [ "$1" = "test" ]
then
    tag="test"
    name="bfanodotest"
    tag="latest"
    name="bfanodo"
else
    echo Argument 1 must be either latest or test. >&2
    exit 1
fi

# Run this just a single time.
# 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}