3 BASEDIR="$(dirname $0)"
12 ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2)
13 ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2)
14 remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}')
19 sendInfoNotification ()
22 wget -q -T 3 -t 1 -O /dev/null "http://$(getRemoteIp):8090/message?msgtype=information&text=$MESSAGE"
25 sendErrorNotification ()
28 wget -q -T 3 -t 1 -O /dev/null "http://$(getRemoteIp):8090/notification?msgtype=critical&text=$MESSAGE"
32 if [ -r "$BASEDIR/truecrypt_config.cfg" ]
34 . "$BASEDIR/truecrypt_config.cfg"
36 echo "truecrypt_config.cfg not found" >&2
40 # make sure to have "/dev/sdb" (not "/dev/sdb1")
41 #DEVICE="${DEVICE:0:8}" the bash way does not work in dash -.-
42 DEVICE="$(echo "$DEVICE" | awk '{print substr($1,0,9)}')"
44 sendInfoNotification "Encrypt device"
47 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" "$DEVICE")"
50 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" -k "$KEYFILE" "$DEVICE")"
55 if [ "$result" != "0" ]
57 sendErrorNotification "Encryption failed"
61 sendInfoNotification "Device encrypted"
67 message="$message\n$($tc_cmd --non-interactive --filesystem=none -p "$PASSWORD" "$DEVICE")"
70 message="$message\n$($tc_cmd --non-interactive --filesystem=none -p "$PASSWORD" -k "$KEYFILE" "$DEVICE")"
74 if [ "$result" != "0" ]
81 sendInfoNotification "Create NTFS filesystem on encrypted device"
83 TC_DEVICE=$(truecrypt -l | awk '{print $3}')
85 message="$message\n$(mkfs.ntfs --quick "$TC_DEVICE")"
88 if [ "$result" != "0" ]
90 sendErrorNotification "Filesystem creation failed"
94 sendInfoNotification "Filesystem successfully created"
96 mount "$TC_DEVICE" "$MOUNTPOINT"
98 sendInfoNotification "Stick is now initialized"