management_scripts/pre_init.sh
changeset 17 980ca72ff1f1
child 21 39d4f181549a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/management_scripts/pre_init.sh	Mon Aug 18 16:08:34 2014 +0200
     1.3 @@ -0,0 +1,24 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +DEVICE="$1"
     1.7 +
     1.8 +# This script makes sure that the stick is unmounted and unused
     1.9 +# Run this Script before the init process
    1.10 +
    1.11 +# make sure to have "/dev/sdb" (not "/dev/sdb1")
    1.12 +#DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.-
    1.13 +DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')"
    1.14 +
    1.15 +# make sure the device is not mounted
    1.16 +umount /var/run/usbmount/*
    1.17 +sleep 1
    1.18 +rmdir /var/run/usbmount/*
    1.19 +umount ${DEVICE}*
    1.20 +
    1.21 +# search for already encrypted volumes
    1.22 +device=$(encryptionprovider.py -g)
    1.23 +
    1.24 +if [ "$?" == "0" ]
    1.25 +then
    1.26 +	encryptionprovider.py -u $device
    1.27 +fi
    1.28 \ No newline at end of file