mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-22 11:39:34 +00:00
docker: Add helper script to build docker config from fragments.
Set PIVX_PARAMSDIR automatically when usecontainers is set. Fix PIVX wallet encryption when added.
This commit is contained in:
parent
ac10c9db76
commit
9677c48f39
5 changed files with 134 additions and 4 deletions
|
@ -833,7 +833,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
|||
params_dir = os.path.join(data_dir, 'pivx-params')
|
||||
downloadPIVXParams(params_dir)
|
||||
fp.write('prune=4000\n')
|
||||
PIVX_PARAMSDIR = os.getenv('PIVX_PARAMSDIR', params_dir)
|
||||
PIVX_PARAMSDIR = os.getenv('PIVX_PARAMSDIR', '/data/pivx-params' if extra_opts.get('use_containers', False) else params_dir)
|
||||
fp.write(f'paramsdir={PIVX_PARAMSDIR}\n')
|
||||
if PIVX_RPC_USER != '':
|
||||
fp.write('rpcauth={}:{}${}\n'.format(PIVX_RPC_USER, salt, password_to_hmac(salt, PIVX_RPC_PWD)))
|
||||
|
@ -1085,7 +1085,7 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
|
|||
try:
|
||||
swap_client = BasicSwap(fp, data_dir, settings, chain)
|
||||
|
||||
coins_to_create_wallets_for = (Coins.PART, Coins.BTC, Coins.LTC, Coins.PIVX)
|
||||
coins_to_create_wallets_for = (Coins.PART, Coins.BTC, Coins.LTC)
|
||||
# Always start Particl, it must be running to initialise a wallet in addcoin mode
|
||||
# Particl must be loaded first as subsequent coins are initialised from the Particl mnemonic
|
||||
start_daemons = ['particl', ] + [c for c in with_coins if c != 'particl']
|
||||
|
@ -1145,7 +1145,10 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
|
|||
swap_client.waitForDaemonRPC(c)
|
||||
swap_client.initialiseWallet(c)
|
||||
if WALLET_ENCRYPTION_PWD != '' and c not in coins_to_create_wallets_for:
|
||||
swap_client.ci(c).changeWalletPassword('', WALLET_ENCRYPTION_PWD)
|
||||
try:
|
||||
swap_client.ci(c).changeWalletPassword('', WALLET_ENCRYPTION_PWD)
|
||||
except Exception as e:
|
||||
logger.warning(f'changeWalletPassword failed for {coin_name}.')
|
||||
|
||||
finally:
|
||||
if swap_client:
|
||||
|
|
1
docker/production/.gitignore
vendored
1
docker/production/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.env
|
||||
docker-compose-prepare.yml
|
||||
docker-compose.yml
|
||||
*_bkp_*.yml
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
- ${DATA_PATH}/particl:/data/particl
|
||||
- ${DATA_PATH}/bitcoin:/data/bitcoin
|
||||
- ${DATA_PATH}/litecoin:/data/litecoin
|
||||
- ${DATA_PATH}/pivx:/data/pivx
|
||||
- ${DATA_PATH}/dash:/data/dash
|
||||
- ${DATA_PATH}/firo:/data/firo
|
||||
environment:
|
||||
- TZ
|
||||
- UI_HTML_PORT
|
||||
|
@ -42,4 +45,19 @@
|
|||
- XMR_WALLET_RPC_USER
|
||||
- XMR_WALLET_RPC_PWD
|
||||
- DEFAULT_XMR_RESTORE_HEIGHT
|
||||
- PIVX_DATA_DIR
|
||||
- PIVX_RPC_HOST
|
||||
- PIVX_RPC_PORT
|
||||
- PIVX_RPC_USER
|
||||
- PIVX_RPC_PWD
|
||||
- DASH_DATA_DIR
|
||||
- DASH_RPC_HOST
|
||||
- DASH_RPC_PORT
|
||||
- DASH_RPC_USER
|
||||
- DASH_RPC_PWD
|
||||
- FIRO_DATA_DIR
|
||||
- FIRO_RPC_HOST
|
||||
- FIRO_RPC_PORT
|
||||
- FIRO_RPC_USER
|
||||
- FIRO_RPC_PWD
|
||||
restart: "no"
|
||||
|
|
|
@ -30,6 +30,11 @@ Set the latest Monero chain height, or the height your wallet must restore from:
|
|||
|
||||
Create docker-compose config:
|
||||
|
||||
# Using the helper script:
|
||||
./scripts/build_yml_files.py -c bitcoin monero
|
||||
|
||||
# Or
|
||||
|
||||
cat compose-fragments/0_start.yml > docker-compose.yml
|
||||
|
||||
# Add the relevant coin fragments
|
||||
|
@ -124,6 +129,20 @@ Start BasicSwap:
|
|||
|
||||
## Add a coin
|
||||
|
||||
|
||||
Stop all running containers
|
||||
|
||||
docker-compose stop
|
||||
|
||||
|
||||
Update docker-compose config:
|
||||
|
||||
Rebuild using the helper script (must list all enabled coins):
|
||||
|
||||
./scripts/build_yml_files.py -c bitcoin monero
|
||||
|
||||
Or
|
||||
|
||||
cat compose-fragments/1_monero-wallet.yml >> docker-compose.yml
|
||||
cat compose-fragments/1_monero-wallet.yml >> docker-compose-prepare.yml
|
||||
|
||||
|
@ -131,10 +150,16 @@ Start BasicSwap:
|
|||
cat compose-fragments/8_monero-daemon.yml >> docker-compose.yml
|
||||
|
||||
|
||||
Prepare config files:
|
||||
|
||||
docker-compose -f docker-compose-prepare.yml build swapprepare
|
||||
|
||||
export ADD_COIN=monero
|
||||
docker-compose -f docker-compose-prepare.yml run --rm swapprepare \
|
||||
basicswap-prepare --nocores --addcoin=${ADD_COIN} --htmlhost="0.0.0.0" --particl_mnemonic=none
|
||||
basicswap-prepare --nocores --usecontainers --addcoin=${ADD_COIN} --htmlhost="0.0.0.0" --particl_mnemonic=none
|
||||
|
||||
|
||||
Prepare wallet:
|
||||
|
||||
docker-compose build monero_daemon
|
||||
docker-compose build
|
||||
|
|
83
docker/production/scripts/build_yml_files.py
Executable file
83
docker/production/scripts/build_yml_files.py
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2023 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
"""
|
||||
Join docker compose fragments
|
||||
"""
|
||||
|
||||
__version__ = '0.1'
|
||||
|
||||
import os
|
||||
import argparse
|
||||
|
||||
|
||||
def get_bkp_offset(filename, ext='yml'):
|
||||
for i in range(1000):
|
||||
if not os.path.exists(f'{filename}_bkp_{i}.{ext}'):
|
||||
return i
|
||||
raise ValueError(f'Unable to get backup filename for: {filename}.{ext}')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('-v', '--version', action='version',
|
||||
version='%(prog)s {version}'.format(version=__version__))
|
||||
parser.add_argument('-c', '--coins', nargs='+', help='<Required> Select coins', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
with_coins = ['particl', ]
|
||||
for coin_name in args.coins:
|
||||
parsed_name = coin_name.lower()
|
||||
if parsed_name not in with_coins:
|
||||
with_coins.append(parsed_name)
|
||||
|
||||
print('Preparing docker compose files with coins:', ','.join(with_coins))
|
||||
|
||||
num_docker_compose = get_bkp_offset('docker-compose')
|
||||
num_docker_compose_prepare = get_bkp_offset('docker-compose-prepare')
|
||||
|
||||
if os.path.exists('docker-compose.yml'):
|
||||
os.rename('docker-compose.yml', f'docker-compose_bkp_{num_docker_compose}.yml')
|
||||
if os.path.exists('docker-compose-prepare.yml'):
|
||||
os.rename('docker-compose-prepare.yml', f'docker-compose-prepare_bkp_{num_docker_compose_prepare}.yml')
|
||||
|
||||
fragments_dir = 'compose-fragments'
|
||||
with open('docker-compose.yml', 'wb') as fp, open('docker-compose-prepare.yml', 'wb') as fpp:
|
||||
with open(os.path.join(fragments_dir, '0_start.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fp.write(line)
|
||||
fpp.write(line)
|
||||
|
||||
for coin_name in with_coins:
|
||||
if coin_name == 'particl':
|
||||
# Nothing to do
|
||||
continue
|
||||
if coin_name == 'monero':
|
||||
with open(os.path.join(fragments_dir, '1_monero-wallet.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fp.write(line)
|
||||
fpp.write(line)
|
||||
with open(os.path.join(fragments_dir, '8_monero-daemon.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fp.write(line)
|
||||
continue
|
||||
with open(os.path.join(fragments_dir, f'1_{coin_name}.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fp.write(line)
|
||||
fpp.write(line)
|
||||
|
||||
with open(os.path.join(fragments_dir, '8_swapclient.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fp.write(line)
|
||||
with open(os.path.join(fragments_dir, '9_swapprepare.yml'), 'rb') as fp_in:
|
||||
for line in fp_in:
|
||||
fpp.write(line)
|
||||
print('Done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue