Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: allow changing the default root directory #2106

Open
liv-io opened this issue Jan 20, 2024 · 8 comments
Open

config: allow changing the default root directory #2106

liv-io opened this issue Jan 20, 2024 · 8 comments

Comments

@liv-io
Copy link

liv-io commented Jan 20, 2024

Background

For some reason, I am not able to define alternative directories via CLI arguments.

  • Arguments that work:

    --configfile=
    --logdir=
    
  • Argument that does not work:

    --datadir=
    

Your environment

  • version of btcd

    btcd version 0.24.0-beta
    
  • which operating system (uname -a on *Nix)

    Linux pod_lnd 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
    
  • any other relevant environment details

    btcd is running as read-only* Podman container
    
    (*except for data directories of course)
    
  • Containerfile

  • Entrypoint/cmd

Steps to reproduce

  • The command I am using is:
    mkdir -p /var/local/btcd/config /var/local/btcd/data /var/local/btcd/log
    
    /usr/local/bin/btcd --configfile=/var/local/btcd/config/btcd.conf --datadir=/var/local/btcd/data --debuglevel=info --externalip=1.2.3.4 --listen=0.0.0.0:8333 --logdir=/var/local/btcd/log --rpclisten=0.0.0.0:8334 --rpcpass=nakamoto --rpcuser=satoshi
    

Expected behaviour

  • I expect btcd to write its output to the respective directories.

Actual behaviour

  • btcd immediately exits and complains about the home directory being read-only. Even when overwriting the default --datadir= location, it still points to the home directory /home/btcd/.btcd/db:
    2024-01-20 19:05:57.634 [INF] BTCD: Version 0.24.0-beta
    2024-01-20 19:05:57.636 [ERR] BTCD: unlinkat /home/btcd/.btcd/db: read-only file system
    2024-01-20 19:05:57.637 [INF] BTCD: Shutdown complete
    
@liv-io
Copy link
Author

liv-io commented Jan 22, 2024

@guggero Thanks again for your support on the lnd issue.

I quickly ran two more tests with btcd.

  • In a read-only environment, btcd immediately stops as it tries to create the .btcd directory in the user's home.

    2024-01-22 11:51:44.252 [INF] BTCD: Version 0.24.0-beta
    2024-01-22 11:51:44.252 [ERR] BTCD: unlinkat /home/btcd/.btcd/db: read-only file system
    2024-01-22 11:51:44.252 [INF] BTCD: Shutdown complete
    
  • In a read-write environment, btcd starts successfully and creates the .btcd directory and rpc.cert, rpc.key files. All other output is written to the defined paths.

    /home/btcd/.btcd
    /home/btcd/.btcd/rpc.cert
    /home/btcd/.btcd/rpc.key
    
  • With the --rpccert= and --rpckey= options defined, it only creates the .btcd directory.

    /home/btcd/.btcd
    
  • The command I've used is:

    /usr/local/bin/btcd --addpeer=10.10.10.11:8333 10.10.10.12:8333 --debuglevel=info --externalip=1.2.3.4 --listen=0.0.0.0:8333 --rpclisten=0.0.0.0:8334 --rpcpass=info --rpcuser=satoshi \
    --configfile=/var/local/btcd/other/config/btcd.conf \
    --datadir=/var/local/btcd/db \
    --logdir=/var/local/btcd/other/log/
    
    • Is there a "global" option for all output as in lnd (i.e. --lnddir=)?

Thanks!

@guggero
Copy link
Collaborator

guggero commented Jan 22, 2024

It looks like there is indeed no global option in btcd and the default home directory is always being created. We should probably fix that, going to change the title to make it more clear what needs to be done.

@guggero guggero changed the title Cannot define alternative directories via CLI arguments config: allow changing the default root directory Jan 22, 2024
@guggero
Copy link
Collaborator

guggero commented Jan 22, 2024

Problem is here: https://github.com/btcsuite/btcd/blob/master/config.go#L529

@liv-io
Copy link
Author

liv-io commented Jan 22, 2024

Thank you very much!

@theedtron
Copy link
Contributor

Hello, I would like to jump on this.

@theedtron
Copy link
Contributor

theedtron commented Apr 8, 2024

Hello @guggero,
Are you able to assist me with info on how flags are added in btcd?

For my approach , I want to add a flag for global home directory that installs everything in the specified path. I'll do a check whether the global flag exists and if true it will replace the path of the default home directory.

@guggero
Copy link
Collaborator

guggero commented Apr 8, 2024

See https://github.com/btcsuite/btcd/blob/master/config.go#L99, those are all flags.

@theedtron
Copy link
Contributor

See https://github.com/btcsuite/btcd/blob/master/config.go#L99, those are all flags.

@guggero Thanks for pointing me in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants