| 1 | #!/bin/sh |
| 2 | |
| 3 | # cryptdisks_stop - wrapper around cryptsetup which parses |
| 4 | # /etc/crypttab, just like mount parses /etc/fstab. |
| 5 | |
| 6 | # Initial code stolen from cryptdisks_start by Jon Dowland <[email protected]> |
| 7 | # Copyright (C) 2008 by Jonas Meurer <[email protected]> |
| 8 | # License: GNU General Public License, v2 or any later |
| 9 | # (https://www.gnu.org/copyleft/gpl.html) |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | if [ $# -lt 1 ]; then |
| 14 | echo "usage: $0 <name>" >&2 |
| 15 | echo >&2 |
| 16 | echo "reads /etc/crypttab and stops the mapping corresponding to <name>" >&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | . /lib/cryptsetup/cryptdisks-functions |
| 21 | |
| 22 | INITSTATE="manual" |
| 23 | DEFAULT_LOUD="yes" |
| 24 | |
| 25 | if [ $(id -u) -ne 0 ]; then |
| 26 | log_warning_msg "$0 needs root privileges" |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | log_action_begin_msg "Stopping crypto disk" |
| 31 | |
| 32 | rv=0 |
| 33 | for name in "$@"; do |
| 34 | remove_mapping "$name" || rv=$? |
| 35 | done |
| 36 | |
| 37 | log_action_end_msg $rv |
| 38 | exit $rv |