ft@17
|
1 |
#!/bin/sh
|
ft@17
|
2 |
|
ft@27
|
3 |
# ------------------------------------------------------------
|
ft@27
|
4 |
# opensecurity package file
|
ft@27
|
5 |
#
|
ft@27
|
6 |
# Autor: X-Net Services GmbH <office@x-net.at>
|
ft@27
|
7 |
#
|
ft@27
|
8 |
# Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
|
ft@27
|
9 |
#
|
ft@27
|
10 |
#
|
ft@27
|
11 |
# X-Net Technologies GmbH
|
ft@27
|
12 |
# Elisabethstrasse 1
|
ft@27
|
13 |
# 4020 Linz
|
ft@27
|
14 |
# AUSTRIA
|
ft@27
|
15 |
# https://www.x-net.at
|
ft@27
|
16 |
#
|
ft@27
|
17 |
# AIT Austrian Institute of Technology
|
ft@27
|
18 |
# Donau City Strasse 1
|
ft@27
|
19 |
# 1220 Wien
|
ft@27
|
20 |
# AUSTRIA
|
ft@27
|
21 |
# http://www.ait.ac.at
|
ft@27
|
22 |
#
|
ft@27
|
23 |
#
|
ft@27
|
24 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
ft@27
|
25 |
# you may not use this file except in compliance with the License.
|
ft@27
|
26 |
# You may obtain a copy of the License at
|
ft@27
|
27 |
#
|
ft@27
|
28 |
# http://www.apache.org/licenses/LICENSE-2.0
|
ft@27
|
29 |
#
|
ft@27
|
30 |
# Unless required by applicable law or agreed to in writing, software
|
ft@27
|
31 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
ft@27
|
32 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
ft@27
|
33 |
# See the License for the specific language governing permissions and
|
ft@27
|
34 |
# limitations under the License.
|
ft@27
|
35 |
# ------------------------------------------------------------
|
ft@27
|
36 |
|
ft@17
|
37 |
DEVICE="$1"
|
ft@17
|
38 |
|
ft@17
|
39 |
# This script makes sure that the stick is unmounted and unused
|
ft@17
|
40 |
# Run this Script before the init process
|
ft@17
|
41 |
|
ft@17
|
42 |
# make sure to have "/dev/sdb" (not "/dev/sdb1")
|
ft@17
|
43 |
#DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.-
|
ft@17
|
44 |
DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')"
|
ft@17
|
45 |
|
ft@17
|
46 |
# make sure the device is not mounted
|
ft@26
|
47 |
chattr -i "/tmp/usbmount"
|
ft@26
|
48 |
umount /tmp/usbmount/*
|
ft@17
|
49 |
sleep 1
|
ft@26
|
50 |
rmdir /tmp/usbmount/*
|
ft@21
|
51 |
umount /media/usb*
|
ft@17
|
52 |
|
ft@32
|
53 |
# sometimes the umount fails with device bussy -> unknown why
|
ft@32
|
54 |
# so try until it works
|
ft@32
|
55 |
counter=0
|
ft@32
|
56 |
while ( [ -n "$(mount | grep "$DEVICE" | head -n 1 | awk '{print $3}')" ] && [ $counter -lt 10 ] )
|
ft@32
|
57 |
do
|
ft@32
|
58 |
sleep 1
|
ft@32
|
59 |
umount "$(mount | grep "$DEVICE" | head -n 1 | awk '{print $3}')"
|
ft@32
|
60 |
counter=$((counter + 1))
|
ft@32
|
61 |
done
|
ft@32
|
62 |
|
ft@32
|
63 |
|
ft@32
|
64 |
|
ft@17
|
65 |
# search for already encrypted volumes
|
ft@17
|
66 |
device=$(encryptionprovider.py -g)
|
ft@17
|
67 |
|
ft@21
|
68 |
if [ "$?" = "0" ]
|
ft@17
|
69 |
then
|
ft@17
|
70 |
encryptionprovider.py -u $device
|
ft@17
|
71 |
fi |