ft@17: #!/bin/sh ft@17: ft@27: # ------------------------------------------------------------ ft@27: # opensecurity package file ft@27: # ft@27: # Autor: X-Net Services GmbH ft@27: # ft@27: # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology ft@27: # ft@27: # ft@27: # X-Net Technologies GmbH ft@27: # Elisabethstrasse 1 ft@27: # 4020 Linz ft@27: # AUSTRIA ft@27: # https://www.x-net.at ft@27: # ft@27: # AIT Austrian Institute of Technology ft@27: # Donau City Strasse 1 ft@27: # 1220 Wien ft@27: # AUSTRIA ft@27: # http://www.ait.ac.at ft@27: # ft@27: # ft@27: # Licensed under the Apache License, Version 2.0 (the "License"); ft@27: # you may not use this file except in compliance with the License. ft@27: # You may obtain a copy of the License at ft@27: # ft@27: # http://www.apache.org/licenses/LICENSE-2.0 ft@27: # ft@27: # Unless required by applicable law or agreed to in writing, software ft@27: # distributed under the License is distributed on an "AS IS" BASIS, ft@27: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ft@27: # See the License for the specific language governing permissions and ft@27: # limitations under the License. ft@27: # ------------------------------------------------------------ ft@27: ft@17: DEVICE="$1" ft@17: ft@17: # This script makes sure that the stick is unmounted and unused ft@17: # Run this Script before the init process ft@17: ft@17: # make sure to have "/dev/sdb" (not "/dev/sdb1") ft@17: #DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.- ft@17: DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')" ft@17: ft@17: # make sure the device is not mounted ft@26: chattr -i "/tmp/usbmount" ft@26: umount /tmp/usbmount/* ft@17: sleep 1 ft@26: rmdir /tmp/usbmount/* ft@21: umount /media/usb* ft@17: ft@32: # sometimes the umount fails with device bussy -> unknown why ft@32: # so try until it works ft@32: counter=0 ft@32: while ( [ -n "$(mount | grep "$DEVICE" | head -n 1 | awk '{print $3}')" ] && [ $counter -lt 10 ] ) ft@32: do ft@32: sleep 1 ft@32: umount "$(mount | grep "$DEVICE" | head -n 1 | awk '{print $3}')" ft@32: counter=$((counter + 1)) ft@32: done ft@32: ft@32: ft@32: ft@17: # search for already encrypted volumes ft@17: device=$(encryptionprovider.py -g) ft@17: ft@21: if [ "$?" = "0" ] ft@17: then ft@17: encryptionprovider.py -u $device ft@17: fi