Skip to content

Commit b89a263

Browse files
committed
[mod] config/.customfunction, add command: cryp-mount(), mount/unmount persional crypto_LUKS paratition.
1 parent 260b8a8 commit b89a263

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

config/.customfunction

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,48 @@ pipenv_correspond(){
102102
done
103103
echo "\e[32mSuccessflly removed all venvs!!\e[0m"
104104
fi
105+
}
106+
107+
# mount/unmount persional crypto_LUKS paratition
108+
cryp-mount(){
109+
local mount=true
110+
local mount_root='/mnt/Backup'
111+
local paratition_locate=$(lsblk -f | grep crypto | cut -d ' ' -f 1 | cut -c 7-)
112+
local help_book="Usage: ys_mount [OPTION]
113+
114+
OPTION:
115+
on, --mount mount personal partition to the $mount_root.
116+
off, --unmount unmount the personal partition.
117+
"
118+
119+
if [ "$#" -gt 0 ]; then
120+
while [ "$#" -gt 0 ]; do
121+
case $1 in
122+
"-h" | "--help" )
123+
echo $help_book
124+
return
125+
;;
126+
"on" | "--mount" )
127+
mount=true
128+
shift 1
129+
;;
130+
"off" | "--unmount" )
131+
mount=false
132+
shift 1
133+
;;
134+
*)
135+
echo "\e[31mWrong command keyword!\e[0m"
136+
return
137+
;;
138+
esac
139+
done
140+
fi
141+
142+
if $mount; then
143+
sudo cryptsetup open /dev/$paratition_locate temp_partition
144+
sudo mount /dev/mapper/temp_partition $mount_root
145+
else
146+
sudo umount $mount_root
147+
sudo cryptsetup close temp_partition
148+
fi
105149
}

0 commit comments

Comments
 (0)