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