forked from zerotier/github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.sh
More file actions
executable file
·30 lines (27 loc) · 926 Bytes
/
post.sh
File metadata and controls
executable file
·30 lines (27 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set -euo pipefail
IFS=$'\n\t'
if [ -z "$(which zerotier-cli)" ]; then
case $(uname -s) in
MINGW64_NT?*)
ztcli="/c/Program Files (x86)/ZeroTier/One/zerotier-cli.bat"
member_id=$("${ztcli}" info | awk '{ print $3 }')
;;
*)
member_id=$(sudo zerotier-cli info | awk '{ print $3 }')
;;
esac
else
ztcli="zerotier-cli"
member_id=$("${ztcli}" info | awk '{ print $3 }')
fi
echo "⏁ Removing Runner from ZeroTier network"
curl -i -s -X DELETE -H "Authorization: token $AUTH_TOKEN" "$API_URL/network/$NETWORK_ID/member/${member_id}" >/tmp/api_delete_output.txt
STATUS_CODE=$(cat /tmp/api_delete_output.txt | grep 'HTTP/' | awk '{print $2}')
if [[ $STATUS_CODE -ge 400 && $STATUS_CODE -le 599 ]]; then
echo "ERROR: Status code: $STATUS_CODE"
echo -e "Complete server response:\n$(cat /tmp/api_delete_output.txt)\n"
exit $STATUS_CODE
else
echo "Success! Status code: $STATUS_CODE"
exit 0
fi