init
This commit is contained in:
commit
ad8211243d
41
dlinux
Executable file
41
dlinux
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
KEY_FILE=~/.dlinux-cli.key
|
||||
|
||||
if [ ! -f $KEY_FILE ]; then
|
||||
echo -e "Key file not found, run:\necho \"[YOUR-API-KEY]\" > $KEY_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_KEY="$(cat $KEY_FILE)"
|
||||
|
||||
print_help() {
|
||||
printf "
|
||||
$0 hello - Get a hello message
|
||||
$0 name - Get your SSHID
|
||||
"
|
||||
}
|
||||
|
||||
# Helper function
|
||||
|
||||
call_api() {
|
||||
curl -X $1 -H "x-ssh-auth: $API_KEY" "https://api.ssh.surf/$2"
|
||||
}
|
||||
|
||||
# Commands
|
||||
|
||||
command_hello() {
|
||||
call_api GET hello | jq .message
|
||||
}
|
||||
|
||||
command_name() {
|
||||
call_api GET name | jq .message
|
||||
}
|
||||
|
||||
# Command handler
|
||||
|
||||
if [ $1 ]; then
|
||||
command_$1
|
||||
else
|
||||
print_help
|
||||
fi
|
Loading…
Reference in New Issue
Block a user