mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 02:42:59 +00:00
74a98d52d7
This adds cjdns-tools which is exposing the tools from $cjdns/tools/ under a command named cjdns-tools (so for ex cjdns "ping" is accessible as cjdns-tools ping <ip>) Additionally patches cjdns tools to read admin pw from /etc/cjdns.keys Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
30 lines
563 B
Bash
30 lines
563 B
Bash
#!/usr/bin/env bash
|
|
|
|
export PATH="@@out@@/tools:$PATH"
|
|
|
|
set -eo pipefail
|
|
|
|
if ! cat /etc/cjdns.keys >/dev/null 2>&1; then
|
|
echo "ERROR: No permission to read /etc/cjdns.keys (use sudo)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z $1 ]]; then
|
|
echo "Cjdns admin"
|
|
|
|
echo "Usage: $0 <command> <args..>"
|
|
|
|
echo
|
|
echo "Commands:" $(find @@out@@/tools -maxdepth 1 -type f | sed -r "s|.+/||g")
|
|
|
|
_sh=$(which sh)
|
|
PATH="@@out@@/tools" PS1="cjdns\$ " "$_sh"
|
|
else
|
|
if [[ ! -e @@out@@/tools/$1 ]]; then
|
|
echo "ERROR: '$1' is not a valid tool" >&2
|
|
exit 2
|
|
else
|
|
"$@"
|
|
fi
|
|
fi
|