Skip to content

Commit

Permalink
docs: usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hugojosefson committed Nov 15, 2024
1 parent 8ecba07 commit 3082a20
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 22 deletions.
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,35 @@ curl -fsSL "/~https://github.com/hugojosefson/dropbear-auto-unlock/tarball/main" \

## Example usage

Basic usage with a single destination:

```sh
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01
```

You can specify multiple alternative addresses for the same server, for example
in case the dropbear has a different IP and/or hostname than the unlocked and
fully booted server:

```sh
pass show zfs_disk_passphrase | dropbear-auto-unlock root@pve-01
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01 --destination.1=root@pve-01-dropbear

# or, more concisely:
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01{,-dropbear}
```

## TODO
You can also unlock multiple separate servers simultaneously:

- [x] Instead of checking first line of ssh server, spawn `ssh` and get a proper
line stream.
- [x] Check if the prompt is an unlock prompt. If so, unlock.
- [x] ~~Check if we can run `zfsunlock`. If so, unlock.~~
- [x] If we're in the server booted, `sleep infinity`, then wait for broken
connection indicating next boot.
- [x] Add timeout arguments/options to `ssh` command.
- [ ] Support secondary destination for same server.
```sh
pass show zfs_disk_passphrase | dropbear-auto-unlock \
--destination.1=root@pve-01 \
--destination.2=root@pve-02

# or, if you have 5 servers, whose dropbear is on the same hostname but with "-dropbear" appended:
pass show zfs_disk_passphrase | dropbear-auto-unlock \
$(for i in {1..5}; do \
for d in "" "-dropbear"; do \
echo "--destination.${i}=root@pve-0${i}${d}"; \
done; \
done)
```
25 changes: 15 additions & 10 deletions readme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@

## Example usage

Basic usage with a single destination:

```sh
"@@include(./example-usage.sh)";
"@@include(./example-usage-simple.sh)";
```

## TODO
You can specify multiple alternative addresses for the same server, for example
in case the dropbear has a different IP and/or hostname than the unlocked and
fully booted server:

```sh
"@@include(./example-usage-alternatives.sh)";
```

- [x] Instead of checking first line of ssh server, spawn `ssh` and get a proper
line stream.
- [x] Check if the prompt is an unlock prompt. If so, unlock.
- [x] ~~Check if we can run `zfsunlock`. If so, unlock.~~
- [x] If we're in the server booted, `sleep infinity`, then wait for broken
connection indicating next boot.
- [x] Add timeout arguments/options to `ssh` command.
- [ ] Support secondary destination for same server.
You can also unlock multiple separate servers simultaneously:

```sh
"@@include(./example-usage-multiple.sh)";
```
5 changes: 5 additions & 0 deletions readme/example-usage-alternatives.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01 --destination.1=root@pve-01-dropbear

# or, more concisely:
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01{,-dropbear}
12 changes: 12 additions & 0 deletions readme/example-usage-multiple.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
pass show zfs_disk_passphrase | dropbear-auto-unlock \
--destination.1=root@pve-01 \
--destination.2=root@pve-02

# or, if you have 5 servers, whose dropbear is on the same hostname but with "-dropbear" appended:
pass show zfs_disk_passphrase | dropbear-auto-unlock \
$(for i in {1..5}; do \
for d in "" "-dropbear"; do \
echo "--destination.${i}=root@pve-0${i}${d}"; \
done; \
done)
2 changes: 2 additions & 0 deletions readme/example-usage-simple.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
pass show zfs_disk_passphrase | dropbear-auto-unlock --destination.1=root@pve-01
2 changes: 0 additions & 2 deletions readme/example-usage.sh

This file was deleted.

0 comments on commit 3082a20

Please sign in to comment.