From 0b3a40bd291e674cd6764aad0556ce65ad170771 Mon Sep 17 00:00:00 2001 From: philemon Date: Sat, 3 Dec 2016 20:14:04 +0300 Subject: [PATCH] [mswin]: Bitcoin .cookie filename fix [opt/cfg]: Add --bitcoin-data-dir option --- data_files/mmgen.cfg | 3 +++ mmgen/globalvars.py | 11 +++++++---- mmgen/opts.py | 21 +++++++++++---------- mmgen/util.py | 3 +-- scripts/deinstall.sh | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/data_files/mmgen.cfg b/data_files/mmgen.cfg index 557a9687..8ccd5954 100644 --- a/data_files/mmgen.cfg +++ b/data_files/mmgen.cfg @@ -29,6 +29,9 @@ # Uncomment to override 'rpcpassword' in bitcoin.conf # rpc_password mypassword +# Uncomment to set the Bitcoin datadir +# bitcoin_data_dir /path/to/datadir + # Set the default hash preset: # hash_preset 3 diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index 54a84982..072407f0 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -90,8 +90,10 @@ class g(object): else os.path.join(home_dir,'.bitcoin') # User opt sets global var: - common_opts = ('color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password') - + common_opts = ( + 'color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password', + 'bitcoin_data_dir' + ) required_opts = ( 'quiet','verbose','debug','outdir','echo_passphrase','passwd_file','stdout', 'show_hash_presets','label','keep_passphrase','keep_hash_preset', @@ -102,11 +104,12 @@ class g(object): ('label','keep_label'), ('tx_id','info'), ('tx_id','terse_info'), - ('batch','rescan'), + ('batch','rescan') ) cfg_file_opts = ( 'color','debug','hash_preset','http_timeout','no_license','rpc_host','rpc_port', - 'quiet','tx_fee','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password' + 'quiet','tx_fee','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password', + 'bitcoin_data_dir' ) env_opts = ( 'MMGEN_BOGUS_WALLET_DATA', diff --git a/mmgen/opts.py b/mmgen/opts.py index a813f458..41127ee1 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -67,16 +67,17 @@ def _show_hash_presets(): # most, but not all, of these set the corresponding global var common_opts_data = """ ---, --color=c Set to '0' to disable color output, '1' to enable ---, --data-dir=d Specify the location of {pnm}'s data directory ---, --no-license Suppress the GPL license prompt ---, --rpc-host=h Communicate with bitcoind running on host 'h' ---, --rpc-port=p Communicate with bitcoind listening on port 'p' ---, --rpc-user=u Override 'rpcuser' in bitcoin.conf ---, --rpc-password=p Override 'rpcpassword' in bitcoin.conf ---, --testnet=1 Set to '1' enable testnet, '0' to disable ---, --skip-cfg-file Skip reading the configuration file ---, --version Print version information and exit +--, --color=0|1 Disable or enable color output +--, --bitcoin-data-dir=d Specify Bitcoin data directory location 'd' +--, --data-dir=d Specify {pnm} data directory location 'd' +--, --no-license Suppress the GPL license prompt +--, --rpc-host=h Communicate with bitcoind running on host 'h' +--, --rpc-port=p Communicate with bitcoind listening on port 'p' +--, --rpc-user=user Override 'rpcuser' in bitcoin.conf +--, --rpc-password=pass Override 'rpcpassword' in bitcoin.conf +--, --testnet=0|1 Disable or enable testnet +--, --skip-cfg-file Skip reading the configuration file +--, --version Print version information and exit """.format(pnm=g.proj_name) def opt_preproc_debug(short_opts,long_opts,skipped_opts,uopts,args): diff --git a/mmgen/util.py b/mmgen/util.py index fcc956ea..8f155134 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -704,8 +704,7 @@ def get_bitcoind_cfg_options(cfg_keys): def get_bitcoind_auth_cookie(): - f = os.path.join(g.bitcoin_data_dir,('',g.testnet_name)[g.testnet], - ('.','_')[g.platform=='win']+'cookie') + f = os.path.join(g.bitcoin_data_dir,('',g.testnet_name)[g.testnet],'.cookie') if file_is_readable(f): return get_lines_from_file(f,'')[0] diff --git a/scripts/deinstall.sh b/scripts/deinstall.sh index 22ec4987..468c2ab6 100755 --- a/scripts/deinstall.sh +++ b/scripts/deinstall.sh @@ -2,7 +2,7 @@ CMD='rm -rf /usr/local/share/mmgen /usr/local/bin/mmgen-* /usr/local/lib/python2.7/dist-packages/mmgen*' -if [ "$EUID" = 0 ]; then +if [ "$EUID" = 0 -o "$HOMEPATH" ]; then set -x; $CMD else set -x; sudo $CMD