summarylogtreecommitdiffstats
path: root/veracrypt_hook_nonroot
blob: 34a85e463bf8e72069e5b3f36b8be9f757e9c060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/ash

run_hook () {
    modprobe -a -q dm-crypt >/dev/null 2>&1
    [ "${quiet}" = "y" ] && CSQUIET=">/dev/null"

    modprobe -a -q fuse >/dev/null 2>&1
    
    # get the veracrypt volume and slot
    if [ -n "${vcdevice}" ]; then
        # get total number of ':' in vcdevice (for devices in /dev/disk/by-id/
        count="$(echo "${vcdevice}" | grep -o ':' | wc -l )"
        cryptdev="$(echo "${vcdevice}" | cut -d: -f1-$count)"
        cryptslot="$(echo "${vcdevice}" | cut -d: -f$(( $count + 1 )) )"
        cryptname="veracrypt${cryptslot}"
    else
        err "No veracrypt device defined on the command line..."
        exit 1
    fi
   
    veracrypt -t --slot="${cryptslot}" --filesystem=none --keyfiles="" --protect-hidden=no "${cryptdev}"
    
    if [ ! -e "/dev/mapper/${cryptname}" ]; then
        err "No such device ${cryptname}"        
    fi

}

# vim: set ft=sh ts=4 sw=4 et: