Created
March 17, 2023 13:23
-
-
Save mcdamo/ed7cdcaf51069cddd025b4bc1adf2250 to your computer and use it in GitHub Desktop.
Script to unlock TrueNAS dataset(s) by way of typed passphrase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Script to unlock TrueNAS dataset(s) by way of typed passphrase | |
set -e | |
# get dir of this script to load conf | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
. $DIR/api.conf | |
# the following should be defined in conf file: | |
#HOST= | |
#API_TOKEN= | |
#datasets=() | |
read -s -p "Enter passphrase: " PASS | |
echo | |
for dataset in "${datasets[@]}"; do | |
echo -n "Unlocking $dataset..." | |
curl "$HOST/api/v2.0/pool/dataset/unlock" -k -X POST \ | |
-H "accept: */*" -H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $API_TOKEN" \ | |
-d '{"id": "'$dataset'","unlock_options": {"key_file": false, "recursive": true, "toggle_attachments": false, "datasets": [{"name" : "'$dataset'" , "passphrase" : "'$PASS'"}]}}' | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment