More work on fulcrum/electrs switching

This commit is contained in:
AaronDewes 2022-03-09 11:55:44 +00:00
parent 1d31c10953
commit 33eba7f156
5 changed files with 38 additions and 16 deletions

1
.gitignore vendored
View File

@ -49,5 +49,6 @@ db/citadel-seed/*
!**/*.license
services/installed.json
services/installed.yaml
use-core-upstream

View File

@ -209,8 +209,8 @@ services:
networks:
default:
ipv4_address: $NEUTRINO_SWITCHER_IP
electrs:
container_name: electrs
electrum:
container_name: electrum
image: ghcr.io/runcitadel/electrs:v0.9.5@sha256:5fdd76415645de14f31c43844dc143b1477f86872d2f73a041c5005d469ed510
working_dir: /data
volumes:

View File

@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
electrs:
container_name: electrs
electrum:
container_name: electrum
image: ghcr.io/runcitadel/electrs:v0.9.5@sha256:5fdd76415645de14f31c43844dc143b1477f86872d2f73a041c5005d469ed510
working_dir: /data
volumes:

View File

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
electrum:
container_name: electrum
image: ghcr.io/runcitadel/fulcrumx
working_dir: /data
volumes:
- ${PWD}/bitcoin:/bitcoin:ro
- ${PWD}/fulcrumx:/data
command: /data/fulcrumx.conf
restart: on-failure
stop_grace_period: 5m
ports:
- "$ELECTRUM_PORT:$ELECTRUM_PORT"
networks:
default:
ipv4_address: $ELECTRUM_IP

View File

@ -20,17 +20,19 @@ scriptDir = os.path.dirname(os.path.realpath(__file__))
nodeRoot = os.path.join(scriptDir, "..")
parser = argparse.ArgumentParser(description="Manage services on your Citadel")
parser.add_argument('action', help='What to do with the service.', choices=["install", "uninstall", "setup"])
parser.add_argument('action', help='What to do with the service.', choices=["set", "uninstall", "setup"])
parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument(
'app', help='The service to perform an action on.', nargs='?')
'service', help='The service to perform an action on.', nargs='?')
parser.add_argument(
'implementation', help='The service to perform an action on.', nargs='?')
args = parser.parse_args()
# Function to install a service
# To install it, read the service's YAML file (nodeRoot/services/name.yml) and add it to the main compose file (nodeRoot/docker-compose.yml)
def installService(name):
def setService(name, implementation):
# Read the YAML file
with open(os.path.join(nodeRoot, "services", name + ".yml"), 'r') as stream:
with open(os.path.join(nodeRoot, "services", name, implementation + ".yml"), 'r') as stream:
service = yaml.safe_load(stream)
# Read the main compose file
@ -46,13 +48,13 @@ def installService(name):
# Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services
# If the file doesn't exist, put [] in it, then run the code below
try:
with open(os.path.join(nodeRoot, "services", "installed.json"), 'r') as stream:
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'r') as stream:
installed = yaml.safe_load(stream)
except FileNotFoundError:
installed = []
installed.append(name)
with open(os.path.join(nodeRoot, "services", "installed.json"), 'w') as stream:
json.dump(list(set(installed)), stream, sort_keys=False)
installed = {}
installed[name] = implementation
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'w') as stream:
yaml.dump(installed, stream, sort_keys=False)
def uninstallService(name):
@ -98,10 +100,10 @@ def installServices():
if args.action == "install":
installService(args.app)
if args.action == "set":
setService(args.service, args.implementation)
elif args.action == "uninstall":
uninstallService(args.app)
uninstallService(args.service)
elif args.action == "setup":
installServices()