Improve installer updates and dependency checks and add command aliases
Release / release (push) Successful in 7m57s

This commit is contained in:
Sebastian Unterschütz committed 2026-10-27 18:10:44 +01:00
1 parent 12cc64fdd9
commit 4b28d441b0
13 files changed
+973 -148

No files matched your search

+53 -3
View File
@@ -46,9 +46,34 @@ The script detects your OS and architecture, downloads the matching binary from
To install to a custom directory:
```sh
INSTALL_DIR=~/.local/bin curl -fsSL https://git.zb-server.de/Sebi/ssh-netbox-wrapper/raw/branch/main/install.sh | bash
curl -fsSL https://git.zb-server.de/Sebi/ssh-netbox-wrapper/raw/branch/main/install.sh | INSTALL_DIR="$HOME/.local/bin" bash
```
### Updating an existing installation
Run the same one-liner again to update to the latest release. The installer uses
an existing `netssh` found in `PATH`, or `/usr/local/bin/netssh` for a new installation.
`INSTALL_DIR` explicitly overrides the destination. The replacement is atomic,
so an installed binary can be updated while it is running.
The installer checks all required programs before downloading or modifying files:
`curl`, `uname`, `sed`, `awk`, `mktemp`, `rm`, `dirname`, `readlink`, `mkdir`, `cat`,
`install`, `mv`, `cp`, `chmod`, `cmp`, and either `sha256sum` (Linux) or `shasum`
(macOS). Bash runs the installer; `sudo` is checked beforehand only if the target
directory requires elevated permissions. Missing programs are listed together;
install them with your package manager and retry. **Python is not required. SHA-256 verification is mandatory:** missing,
duplicate or mismatched checksums abort the update before replacing anything.
It also consolidates netssh integration in existing Bash, Zsh and Fish profiles
and creates the current shell's rc file when needed. Old standalone netssh hooks,
inline host aliases and `eval "$(netssh alias)"` entries are replaced by a single
managed block per rc file. Legacy entries in login profiles are removed as well.
Other shell settings, NetBox configuration, cache and local notes are preserved.
Every changed existing profile gets a `.netssh-backup.XXXXXX` backup; symlinks
and permissions are preserved. `XDG_CONFIG_HOME`, `XDG_CACHE_HOME` and `ZDOTDIR`
are respected. Alias files and installed shell completions are regenerated.
Open a **new terminal** after updating to load the new aliases and hooks.
### Build from source
```sh
@@ -68,7 +93,7 @@ Re-run it at any time to change settings without editing the file manually:
netssh configure
```
The wizard walks through NetBox connection, SSH defaults, resolver strategies, and cache TTL,
The wizard walks through NetBox connection, SSH defaults, resolver strategies, cache TTL, and an optional command alias,
then saves to `~/.config/netssh.yaml`.
### Manual config
@@ -109,6 +134,31 @@ shortcuts:
Any value can be overridden with environment variables (`NETSSH_NETBOX_URL`, `NETSSH_NETBOX_TOKEN`, etc.).
### Short command alias
In `netssh configure`, set **Command alias** to `j` to use `j` anywhere you would
use `netssh`:
```sh
j # interactive server search
j server01 # connect to a server
j notes show server01
```
The setting is saved as:
```yaml
shell:
alias: j
```
The wizard regenerates shell aliases and installs the current shell's hook when
an alias is set. Open a new terminal (or follow the displayed reload command).
Changing the setting replaces the old generated alias; leaving it empty disables
it for new shells. The command alias takes priority over a host alias with the
same name and works even when no servers are cached. Environment override:
`NETSSH_SHELL_ALIAS=j`.
### API tokens
NetBox supports two token formats:
@@ -457,7 +507,7 @@ Both are non-blocking — the refresh runs as a background process and never del
## Development
```sh
go test ./... # run all tests
go test ./... # includes offline installer/update tests
go build ./... # build all packages
```