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

make tezos-client command work without passing client dir as param #369

Merged
merged 1 commit into from
Feb 22, 2022

Conversation

nicolasochem
Copy link
Collaborator

This is very neat because I can open a shell into the node or baker and
type tezos-client list known addresses and it just works.

Q: why a symink instead of moving the actual dir to
/home/tezos/.tezos-client ?

A: the potential for breakage is high if we move the dir. This makes the
startup script a bit longer but there is virtually no risk of breakage.

This is very neat because I can open a shell into the node or baker and
type `tezos-client list known addresses` and it just works.

Q: why a symink instead of moving the actual dir to
/home/tezos/.tezos-client ?

A: the potential for breakage is high if we move the dir. This makes the
startup script a bit longer but there is virtually no risk of breakage.
Comment on lines +20 to +22
# ensure we can run tezos-client commands without specifying client dir
ln -s /var/tezos/client /home/tezos/.tezos-client

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great trick :)

A few things:

  • I don't think the cmd just like this will work. We need to remove the directory first. Otherwise the symlink gets created inside the target. Instead of becoming the target. https://askubuntu.com/questions/600714/creating-a-symlink-from-one-folder-to-another-with-different-names

    ~ $ ln -s /var/tezos/client /home/tezos/.tezos-client/
    ~ $ ls -l /home/tezos/.tezos-client/
    total 0
    lrwxrwxrwx    1 tezos    nogroup         17 Feb 18 05:20 client -> /var/tezos/client
    ~ $ tezos-client list known addresses
    ~ $ unlink /home/tezos/.tezos-client/client
    ~ $ ls -l /home/tezos/.tezos-client/
    total 0
    
    # Now remove the directory
    ~ $ rm -r .tezos-client/
    ~ $ ln -s /var/tezos/client/ .tezos-client
    ~ $ ls -la
    ...
    lrwxrwxrwx    1 tezos    nogroup         18 Feb 18 05:43 .tezos-client -> /var/tezos/client/
    ~ $ ls -l .tezos-client/
    total 32
    -rw-r--r--    1 tezos    nogroup      10297 Feb 18 05:44 NetXxkAx4woPL_baker_state
    -rw-r--r--    1 tezos    nogroup        408 Feb 18 05:44 NetXxkAx4woPL_highwatermarks
    -rw-r--r--    1 tezos    nogroup       4082 Feb 18 05:38 NetXxkAx4woPL_nonces
    -rw-r--r--    1 root     root           661 Feb 18 00:04 public_key_hashs
    -rw-r--r--    1 root     root          1655 Feb 18 00:04 public_keys
    -rw-r--r--    1 root     root           132 Feb 18 00:04 secret_keys
    -rw-r--r--    1 tezos    nogroup          0 Feb 18 00:08 wallet_lock
    ~ $ tezos-client list known addresses
    oxheadbaker: tz1....
  • Why not move the ln above here so we don't need -d?

    CLIENT="$TEZ_BIN/tezos-client -d $CLIENT_DIR"
    CMD="$TEZ_BIN/tezos-$DAEMON-$proto_command -d $CLIENT_DIR"

  • You mentioned this makes the startup script take longer. How much longer?

  • Do you think we would ever want in the future to stop using /var/tezos and use the default .tezos-client dir instead? Or there's not much of a reason to switch at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work, I tried. When the node starts, there is no .tezos-client in the homedir. And it starts from a clean homedir each time the container starts (homedir is not mounted). If some future octez container somehow has a .tezos-client in it, then what you describe will happen. I think we are fine, though.

Why not move the ln above here so we don't need -d?

As far as the script goes, I think it's ok to be very explicit and not rely on the existence of the symlink. This tricks helps humans but machines can deal with a more complicated command.

You mentioned this makes the startup script take longer. How much longer?

I meant longer in terms of lines of code, not exec time.

Do you think we would ever want in the future to stop using /var/tezos and use the default .tezos-client dir instead? Or there's not much of a reason to switch at this point.

I'm afraid of breakage so I went for this hack instead so we don't have to worry about it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds great. thank you :)

@nicolasochem nicolasochem merged commit e76713a into master Feb 22, 2022
nicolasochem added a commit that referenced this pull request May 21, 2022
so one can open a shell into the signer, and run

```
tezos-signer list known addresses
```
and see the addresses in the output, without passing an actual data dir.

in the spirit of #369, but for the signer
nicolasochem added a commit that referenced this pull request May 21, 2022
so one can open a shell into the signer, and run

```
tezos-signer list known addresses
```
and see the addresses in the output, without passing an actual data dir.

in the spirit of #369, but for the signer
nicolasochem added a commit that referenced this pull request May 23, 2022
so one can open a shell into the signer, and run

```
tezos-signer list known addresses
```
and see the addresses in the output, without passing an actual data dir.

in the spirit of #369, but for the signer
@harryttd harryttd deleted the easier_tezos_client branch May 24, 2022 00:41
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

Successfully merging this pull request may close these issues.

2 participants