add some zerotier scripts
This commit is contained in:
parent
0a6221d6aa
commit
f5fbd372a2
1 changed files with 15 additions and 5 deletions
|
@ -5,6 +5,8 @@ let
|
|||
export TOKEN=$(cat /var/lib/zerotier-one/authtoken.secret)
|
||||
'';
|
||||
zerotierCommand = name: command: pkgs.writers.writeBashBin name ''
|
||||
set -e
|
||||
set -o pipefail
|
||||
export PATH=${pkgs.curl}/bin:${pkgs.gojq}/bin:${pkgs.zerotierone}/bin:$PATH
|
||||
${zerotierSetup}
|
||||
${command}
|
||||
|
@ -15,8 +17,16 @@ in
|
|||
(zerotierCommand "zerotier-script-members" ''
|
||||
curl "http://localhost:9993/controller/network/''${NWID}/member" -H "X-ZT1-AUTH: ''${TOKEN}" | gojq
|
||||
'')
|
||||
(zerotierCommand "zerotier-script-nodeid" ''
|
||||
zerotier-cli info | cut -d " " -f 3
|
||||
(zerotierCommand "zerotier-script-delete-member" ''
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Memid is missing."
|
||||
exit 1
|
||||
fi
|
||||
export MEMID=$1
|
||||
echo "deauthorized $MEMID"
|
||||
curl -X POST "http://localhost:9993/controller/network/''${NWID}/member/''${MEMID}" -H "X-ZT1-AUTH: ''${TOKEN}" -d '{"authorized": false}' | gojq
|
||||
echo "delete $MEMID"
|
||||
curl -X DELETE "http://localhost:9993/controller/network/''${NWID}/member/''${MEMID}" -H "X-ZT1-AUTH: ''${TOKEN}" | gojq
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue