management_scripts/pre_init.sh
author ft
Mon, 18 Aug 2014 16:08:34 +0200
changeset 17 980ca72ff1f1
child 21 39d4f181549a
permissions -rwxr-xr-x
changed init process
added pre and post init script
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@17
    13
umount /var/run/usbmount/*
ft@17
    14
sleep 1
ft@17
    15
rmdir /var/run/usbmount/*
ft@17
    16
umount ${DEVICE}*
ft@17
    17
ft@17
    18
# search for already encrypted volumes
ft@17
    19
device=$(encryptionprovider.py -g)
ft@17
    20
ft@17
    21
if [ "$?" == "0" ]
ft@17
    22
then
ft@17
    23
	encryptionprovider.py -u $device
ft@17
    24
fi