3 # ------------------------------------------------------------
4 # opensecurity package file
6 # Autor: X-Net Services GmbH <office@x-net.at>
8 # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
11 # X-Net Technologies GmbH
15 # https://www.x-net.at
17 # AIT Austrian Institute of Technology
18 # Donau City Strasse 1
21 # http://www.ait.ac.at
24 # Licensed under the Apache License, Version 2.0 (the "License");
25 # you may not use this file except in compliance with the License.
26 # You may obtain a copy of the License at
28 # http://www.apache.org/licenses/LICENSE-2.0
30 # Unless required by applicable law or agreed to in writing, software
31 # distributed under the License is distributed on an "AS IS" BASIS,
32 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 # See the License for the specific language governing permissions and
34 # limitations under the License.
35 # ------------------------------------------------------------
37 BASEDIR="$(dirname $0)"
46 ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2)
47 ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2)
48 remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}')
53 sendInfoNotification ()
56 wget -q -T 3 -t 1 -O /dev/null "http://$(getRemoteIp):8090/message?msgtype=information&text=$MESSAGE"
59 sendErrorNotification ()
62 wget -q -T 3 -t 1 -O /dev/null "http://$(getRemoteIp):8090/notification?msgtype=critical&text=$MESSAGE"
66 if [ -r "$BASEDIR/truecrypt_config.cfg" ]
68 . "$BASEDIR/truecrypt_config.cfg"
70 echo "truecrypt_config.cfg not found" >&2
74 # make sure to have "/dev/sdb" (not "/dev/sdb1")
75 #DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.-
76 DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')"
78 sendInfoNotification "Encrypt device"
81 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" "$DEVICE")"
84 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" -k "$KEYFILE" "$DEVICE")"
89 if [ "$result" != "0" ]
91 sendErrorNotification "Encryption failed"
95 sendInfoNotification "Device encrypted"
101 message="$message\n$($tc_cmd --non-interactive --filesystem=none -p "$PASSWORD" "$DEVICE")"
104 message="$message\n$($tc_cmd --non-interactive --filesystem=none -p "$PASSWORD" -k "$KEYFILE" "$DEVICE")"
108 if [ "$result" != "0" ]
115 sendInfoNotification "Create NTFS filesystem on encrypted device"
117 TC_DEVICE=$(truecrypt -l | awk '{print $3}')
119 message="$message\n$(mkfs.ntfs --quick "$TC_DEVICE")"
122 if [ "$result" != "0" ]
124 sendErrorNotification "Filesystem creation failed"
128 sendInfoNotification "Filesystem successfully created"
130 mount "$TC_DEVICE" "$MOUNTPOINT"
132 sendInfoNotification "Stick is now initialized"