management_scripts/pre_init.sh
author ft
Tue, 04 Nov 2014 14:21:53 +0100
changeset 26 7ee697669fb9
parent 21 39d4f181549a
child 27 a8c8d86b8501
permissions -rwxr-xr-x
changed workflow
ft@17
     1
#!/bin/sh
ft@17
     2
ft@17
     3
DEVICE="$1"
ft@17
     4
ft@17
     5
# This script makes sure that the stick is unmounted and unused
ft@17
     6
# Run this Script before the init process
ft@17
     7
ft@17
     8
# make sure to have "/dev/sdb" (not "/dev/sdb1")
ft@17
     9
#DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.-
ft@17
    10
DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')"
ft@17
    11
ft@17
    12
# make sure the device is not mounted
ft@26
    13
chattr -i "/tmp/usbmount"
ft@26
    14
umount /tmp/usbmount/*
ft@17
    15
sleep 1
ft@26
    16
rmdir /tmp/usbmount/*
ft@21
    17
umount /media/usb*
ft@17
    18
ft@17
    19
# search for already encrypted volumes
ft@17
    20
device=$(encryptionprovider.py -g)
ft@17
    21
ft@21
    22
if [ "$?" = "0" ]
ft@17
    23
then
ft@17
    24
	encryptionprovider.py -u $device
ft@17
    25
fi