Skip to content

Commit

Permalink
Merge pull request #26 from 007revad/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
007revad authored Apr 17, 2024
2 parents f603877 + f83c8cc commit 78ff26a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.1.13
- Changed the location of .rkey files for decrypting volumes from hard coded to a variable.
- Minor bug fix to avoid possible cryptvol already exists message.

v1.1.12
- Added support for encrypted volumes.
- Added check if volume is already mounted.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ There are 2 ways you can access you data:
<p align="left">DSM 6 Classic RAID single volume</p>
<p align="left"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src="/images/image-md-2.png"></p>

<br>

<p align="left">DSM 7 Encrypted volume</p>
<p align="left"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src="/images/image-encrypted-volume-2.png"></p>

Binary file added images/image-encrypted-volume-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 16 additions & 7 deletions syno_recover_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#mount_path="/media"
mount_path="/home/ubuntu"

home_path="/home/ubuntu" # Location of .rkey files for decrypting volumes

scriptver="v1.1.12"

scriptver="v1.1.13"
script=Synology_Recover_Data
repo="007revad/Synology_Recover_Data"

Expand Down Expand Up @@ -273,7 +275,7 @@ fi
get_rkeys(){
# [NASNAME]_volume1.rkey
rkeys=( )
for rkey in /home/ubuntu/*_volume"${device_path##*_}".rkey; do
for rkey in "${home_path}"/*_volume"${device_path##*_}".rkey; do
#echo "$rkey" # debug
if [[ -f "$rkey" ]]; then
rkeys+=("$rkey")
Expand All @@ -288,7 +290,7 @@ select_rkey(){
select recovery_key in "${rkeys[@]}"; do
if [[ $recovery_key ]]; then
if [[ -f $recovery_key ]]; then
echo "You selected $recovery_key"
echo -e "You selected $recovery_key"
break
else
ding
Expand All @@ -301,7 +303,7 @@ select_rkey(){
done
elif [[ ${#rkeys[@]} -eq 1 ]]; then
recovery_key=${rkeys[0]}
echo "Using recovery key: $recovery_key"
echo -e "Using recovery key: $recovery_key"
else
ding
echo -e "Line ${LINENO}: ${Error}ERROR${Off} No recovery key found!"
Expand Down Expand Up @@ -335,12 +337,18 @@ if [[ $maybe_encripted == "yes" ]]; then

# Decrypt the encrypted volume
cryptvol="cryptvol_${device_path##*_}"
#echo "cryptovol: $device_path" # debug
#echo "cryptvol: $device_path" # debug

# Remove any existing /dev/mapper/cryptvol_${device_path##*_}
if [[ -e "/dev/mapper/$cryptvol" ]]; then
umount -f "/dev/mapper/$cryptvol"
dmsetup remove -f "/dev/mapper/$cryptvol"
fi

# cryptsetup open --allow-discards /dev/vgX/volume_Y cryptvol_Y -S 1 -d ${base64_decode_output_path}
cryptsetup open --allow-discards "$device_path" "$cryptvol" -S 1 -d "${base64_decode_output_path}"
code="$?"
if [[ $code -gt "0" ]]; then exit 1; fi
#if [[ $code -gt "0" ]]; then exit 1; fi

# Set device_path
device_path="/dev/mapper/$cryptvol"
Expand All @@ -354,7 +362,8 @@ fi
echo -e "\nCreating mount point folder(s)"
if [[ ! -d "${mount_path}/$mount_dir" ]]; then
#mkdir -m777 "${mount_path}/$mount_dir"
mkdir -m444 "${mount_path}/$mount_dir"
#mkdir -m444 "${mount_path}/$mount_dir"
mkdir -m744 "${mount_path}/$mount_dir"

# Allow user to unmount volume from UI
chown ubuntu "${mount_path}/$mount_dir"
Expand Down

0 comments on commit 78ff26a

Please sign in to comment.