Debian Codegraph @

debian/scripts/cryptdisks_start

raw symbols SCIP
1 #!/bin/sh
2
3 # cryptdisks_start - wrapper around cryptsetup which parses
4 # /etc/crypttab, just like mount parses /etc/fstab.
5
6 # Initial code and (c) 2007 Jon Dowland <[email protected]>
7 # License: GNU General Public License, v2 or any later
8 # (https://www.gnu.org/copyleft/gpl.html)
9
10 set -e
11
12 . /lib/cryptsetup/cryptdisks-functions
13
14 INITSTATE="manual"
15 DEFAULT_LOUD="yes"
16 FORCE_START="yes"
17
18 usage() {
19 local rv="${1:-1}"
20 echo "Usage: $0 [-r|--readonly] <name> [.. <name>]" >&2
21 echo >&2
22 echo "reads $TABFILE and starts the mapping corresponding to <name>" >&2
23 exit $rv
24 }
25
26 CRYPTTAB_EXTRA_OPTIONS=
27 while [ $# -gt 0 ]; do
28 case "$1" in
29 -r|--readonly) CRYPTTAB_EXTRA_OPTIONS="${CRYPTTAB_EXTRA_OPTIONS:+$CRYPTTAB_EXTRA_OPTIONS,}readonly";;
30 -h|--help|-\?) usage 0;;
31 --) shift; break;;
32 -*) echo "Error: unknown option '$1'" >&2; usage 1;;
33 *) break;;
34 esac
35 shift
36 done
37 [ $# -gt 0 ] || usage 1
38
39 if [ $(id -u) -ne 0 ]; then
40 log_warning_msg "$0 needs root privileges"
41 exit 1
42 fi
43
44 log_action_begin_msg "Starting crypto disk"
45 mount_fs
46
47 rv=0
48 for name in "$@"; do
49 if ! crypttab_find_entry --quiet "$name"; then
50 device_msg "$name" "failed, not found in crypttab"
51 rv=1
52 else
53 if [ -n "$CRYPTTAB_EXTRA_OPTIONS" ]; then
54 CRYPTTAB_OPTIONS="$CRYPTTAB_OPTIONS,$CRYPTTAB_EXTRA_OPTIONS"
55 _CRYPTTAB_OPTIONS="$_CRYPTTAB_OPTIONS,$CRYPTTAB_EXTRA_OPTIONS"
56 fi
57 setup_mapping || rv=$?
58 fi
59 done
60 umount_fs
61
62 log_action_end_msg $rv
63 exit $rv