28 lines
564 B
Bash
28 lines
564 B
Bash
#!/bin/bash
|
|
MapName=$1
|
|
ContainerName="${MapName}foo"
|
|
|
|
red=`tput setaf 1`
|
|
green=`tput setaf 2`
|
|
reset=`tput sgr0`
|
|
|
|
CMD=("umount" "/dev/mapper/${MapName}")
|
|
if ! "${CMD[@]}"; then
|
|
echo "${red}can't umount ${MapName}${reset}"
|
|
exit 1
|
|
fi
|
|
|
|
CMD=("lvchange" "-a" "n" "/dev/mapper/${MapName}")
|
|
if ! "${CMD[@]}"; then
|
|
echo "${red}can't remove lv ${MapName}${reset}"
|
|
exit 1
|
|
fi
|
|
|
|
CMD=("cryptsetup" "luksClose" "$ContainerName")
|
|
if ! "${CMD[@]}"; then
|
|
echo "${red}can't close luks ${ContainerName}${reset}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "${green}success umount ${MapName} ${reset}"
|