-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnraidScript.txt
More file actions
50 lines (38 loc) · 1.52 KB
/
Copy pathUnraidScript.txt
File metadata and controls
50 lines (38 loc) · 1.52 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
#ZFS Datashare Unlock Script - Dwindle2234 17-Aug-24
#Script assumes that all datasets were created with the same password file located in /root
# Parameters
FILENAME="unraidpass.txt" # name of file on NETGATE
SSHPASSWORD="XXXXX" # change this to your pfSense's user password
SOURCEDEVICE="ssh_user@192.168.50.1" # Netgate/pfSenseSource device IP and user name
SOURCEPATH="/home/ssh_user" # Location of password file on NETGATE
#
NOTIFY="/usr/local/emhttp/webGui/scripts/notify"
function unlock () {
echo Attempting to unlock dataset $1
#Load the password file
zfs load-key $1
#Mount the dataset
zfs mount $1
#report
if [ $? -eq 0 ]; then
$NOTIFY -i "normal" -s "ZFS Dataset Unlock Script" \
-d "The dataset $1 WAS unlocked successfully."
else
$NOTIFY -i "warning" -s "ZFS Dataset Unlock Script" \
-d "The dataset $1 was NOT unlocked successfully. Action will be needed."
fi
}
#Main Program Starts
echo Script started
#Download the password file to /root (assumes same file for each share)
sshpass -p$SSHPASSWORD scp -o StrictHostKeyChecking=no $SOURCEDEVICE:$SOURCEPATH/$FILENAME /root
if [ ! -e "/root/$FILENAME" ]; then
$NOTIFY -i "alert" -s "ZFS Dataset Unlock Script" \
-d "The password file was not retrieved from Netgate. Encrypted datasets CANNOT be unlocked."
exit
fi
#Specify shares to unlock
unlock "disk1/general"
echo
echo Unlock encrypted shares script finished.