Skip to content

Commit

Permalink
cluster: ready repo for subtree into plebnet-playground-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed May 20, 2022
1 parent d77da09 commit bdcf5a9
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 21 deletions.
91 changes: 91 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
SHELL := /bin/bash

PWD ?= pwd_unknown

THIS_FILE := $(lastword $(MAKEFILE_LIST))
export THIS_FILE
TIME := $(shell date +%s)
export TIME

ifeq ($(docker),)
DOCKER := $(shell which docker)
else
DOCKER := $(docker)
endif
export DOCKER

ifeq ($(compose),)
DOCKER_COMPOSE := $(shell which docker-compose)
else
DOCKER_COMPOSE := $(compose)
endif
export DOCKER_COMPOSE



PYTHON := $(shell which python)
export PYTHON
PYTHON2 := $(shell which python2)
export PYTHON2
PYTHON3 := $(shell which python3)
export PYTHON3

PIP := $(shell which pip)
export PIP
PIP2 := $(shell which pip2)
export PIP2
PIP3 := $(shell which pip3)
export PIP3

python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1)))
python_version_major := $(word 1,${python_version_full})
python_version_minor := $(word 2,${python_version_full})
python_version_patch := $(word 3,${python_version_full})

my_cmd.python.3 := $(PYTHON3) some_script.py3
my_cmd := ${my_cmd.python.${python_version_major}}

PYTHON_VERSION := ${python_version_major}.${python_version_minor}.${python_version_patch}
PYTHON_VERSION_MAJOR := ${python_version_major}
PYTHON_VERSION_MINOR := ${python_version_minor}

export python_version_major
export python_version_minor
export python_version_patch
export PYTHON_VERSION

# PROJECT_NAME defaults to name of the current directory.
ifeq ($(project),)
PROJECT_NAME := $(notdir $(PWD))
else
PROJECT_NAME := $(project)
endif
export PROJECT_NAME




.PHONY: venv
venv:
test -d .venv || $(PYTHON3) -m virtualenv .venv
( \
source .venv/bin/activate; pip install -r requirements.txt; \
);
@echo "To activate (venv)"
@echo "try:"
@echo ". .venv/bin/activate"
@echo "or:"
@echo "make test-venv"
##: test-venv source .venv/bin/activate; pip install -r requirements.txt;
test-venv:
# insert test commands here
test -d .venv || $(PYTHON3) -m virtualenv .venv
( \
source .venv/bin/activate; pip install -r requirements.txt; \
);
#######################
.PHONY: prune-network
prune-network:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) down
docker network rm $(PROJECT_NAME)_default 2>/dev/null || echo "retry..."
#######################
4 changes: 1 addition & 3 deletions up-generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ python plebnet_generate.py TRIPLET=$TRIPLET bitcoind=$bitcoind lnd=$lnd tor=$tor

#Remove
docker-compose down
sudo rm -rf volumes


#Create Datafile
mkdir -p volumes

mkdir volumes
for (( i=0; i<=$bitcoind-1; i++ ))
do
mkdir -p volumes/bitcoin_datadir_$i
Expand Down
67 changes: 49 additions & 18 deletions up-x64.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
if [[ $# -ne 1 ]];
then
then
echo "up-x64.sh (# of instances)"
exit
fi

while ! docker system info > /dev/null 2>&1; do
echo "Waiting for docker to start..."
if [[ "$(uname -s)" == "Linux" ]]; then
systemctl restart docker.service
fi
if [[ "$(uname -s)" == "Darwin" ]]; then
open --background -a /./Applications/Docker.app/Contents/MacOS/Docker
fi

sleep 1;

done

#This is for internal testing only
declare TRIPLET=x86_64-linux-gnu
declare torcount=$(expr $1 / 8 + 1)
TRIPLET=x86_64-linux-gnu
torcount=`expr $1 / 3 + 1`
echo $torcount
python plebnet_generate.py TRIPLET=x86_64-linux-gnu bitcoind=$1 lnd=$1 tor=$torcount

#Remove
docker-compose down
sudo rm -rf volumes

docker compose down || docker-compose down
sudo -s chown -R $(id -u) *
sudo -s rm -rf volumes

#Create Datafile
sudo -s mkdir volumes

mkdir volumes
sudo -s chown -R $(id -u) *
declare n=$1
for (( i=0; i<=n-1; i++ ))
do
mkdir volumes/lnd_datadir_$i
mkdir volumes/bitcoin_datadir_$i

echo $i
mkdir -p volumes/lnd_datadir_$i
mkdir -p volumes/bitcoin_datadir_$i

# mkdir volumes/tor_torrcdir_1
done
for (( i=0; i<=torcount-1; i++ ))
do
mkdir volumes/tor_datadir_$i
mkdir volumes/tor_servicesdir_$i
mkdir volumes/tor_torrcdir_$i
for (( i=0; i<=torcount; i++ ))
do
echo $i
mkdir -p volumes/tor_datadir_$i
mkdir -p volumes/tor_servicesdir_$i
mkdir -p volumes/tor_torrcdir_$i
done

while ! docker system info > /dev/null 2>&1; do
echo "Waiting for docker to start..."
if [[ "$(uname -s)" == "Linux" ]]; then
systemctl restart docker.service
fi
if [[ "$(uname -s)" == "Darwin" ]]; then
open --background -a /./Applications/Docker.app/Contents/MacOS/Docker
fi

sleep 1;

done

docker-compose build --build-arg TRIPLET=$TRIPLET
docker-compose up -d
docker compose build --parallel --build-arg TRIPLET=$TRIPLET || docker-compose build --parallel --build-arg TRIPLET=$TRIPLET
docker compose up --remove-orphans -d || docker-compose up --remove-orphans -d



0 comments on commit bdcf5a9

Please sign in to comment.