27 lines
710 B
Plaintext
Executable File
27 lines
710 B
Plaintext
Executable File
#/!/bin/bash
|
|
function usage() {
|
|
echo "Usage: ssh_locker_helper <user> <action>"
|
|
echo "Actions:"
|
|
echo " lock - Lock the SSH locker"
|
|
echo " unlock - Unlock the SSH locker"
|
|
}
|
|
if [ -z "$SERVER_API_ACCESS_TOKEN" ]; then
|
|
echo "Please set the SERVER_API_ACCESS_TOKEN environment variable."
|
|
exit 1
|
|
fi
|
|
if [ -z "$1" ] || [ -z "$2" ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
response=$(curl -s -o /dev/null -w "%{redirect_url}" \
|
|
-X POST https://alexpires.me/api/ssh_locker/action \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-Auth-Token: $SERVER_API_ACCESS_TOKEN" \
|
|
-d '{"user":"'$1'","action":"'$2'"}')
|
|
|
|
if [ -n "$response" ]; then
|
|
xdg-open "$response"
|
|
else
|
|
echo "No redirect URL received."
|
|
fi |