1#!/usr/bin/env bash
2
3export PATH="@@out@@/tools:$PATH"
4
5set -eo pipefail
6
7if ! cat /etc/cjdns.keys >/dev/null 2>&1; then
8 echo "ERROR: No permission to read /etc/cjdns.keys (use sudo)" >&2
9 exit 1
10fi
11
12if [[ -z $1 ]]; then
13 echo "Cjdns admin"
14
15 echo "Usage: $0 <command> <args..>"
16
17 echo
18 echo "Commands:" $(find @@out@@/tools -maxdepth 1 -type f | sed -r "s|.+/||g")
19
20 _sh=$(which sh)
21 PATH="@@out@@/tools" PS1="cjdns\$ " "$_sh"
22else
23 if [[ ! -e @@out@@/tools/$1 ]]; then
24 echo "ERROR: '$1' is not a valid tool" >&2
25 exit 2
26 else
27 "$@"
28 fi
29fi