Added ssh-keys default help function

This commit is contained in:
Omar Shehata
2016-11-28 02:59:32 +00:00
parent 80e0bcc743
commit 74db5b9d3b
3 changed files with 34 additions and 15 deletions

View File

@@ -1,26 +1,14 @@
#!/usr/bin/env bash
[[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
case "$1" in
help | ssh-keys:help)
help_content_func () {
declare desc="return ssh-keys plugin help content"
cat<<help_content
ssh-keys, Manage public ssh keys that are allowed to connect to Dokku
ssh-keys:list, List of all authorized dokku public ssh keys
ssh-keys:add <name> [/path/to/key], Add a new public key by pipe or path
ssh-keys:remove <name>, Remove SSH public key by name
help_content
}
if [[ $1 = "ssh-keys:help" ]] ; then
echo -e 'Usage: dokku ssh-keys[:COMMAND]'
echo ''
echo 'Manage public ssh keys that are allowed to connect to Dokku'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
help_formatted
else
help_content_func
fi

View File

@@ -2,6 +2,25 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
help_formatted (){
echo -e 'Usage: dokku ssh-keys[:COMMAND]'
echo ''
echo 'Manage public ssh keys that are allowed to connect to Dokku'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
}
help_content_func () {
declare desc="return ssh-keys plugin help content"
cat<<help_content
ssh-keys, Manage public ssh keys that are allowed to connect to Dokku
ssh-keys:list, List of all authorized dokku public ssh keys
ssh-keys:add <name> [/path/to/key], Add a new public key by pipe or path
ssh-keys:remove <name>, Remove SSH public key by name
help_content
}
verify_ssh_key_file() {
declare desc="Test that public key is valid"
[[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
ssh_keys_main_cmd() {
declare desc="return ssh-keys plugin help content"
local cmd="ssh-keys"
help_formatted
}
ssh_keys_main_cmd "$@"