1.1 --- a/truecrypt_scripts/truecrypt_init.sh Mon Jul 28 15:27:10 2014 +0200
1.2 +++ b/truecrypt_scripts/truecrypt_init.sh Tue Jul 29 11:12:10 2014 +0200
1.3 @@ -6,6 +6,29 @@
1.4 PASSWORD="$3"
1.5 KEYFILE="$4"
1.6
1.7 +
1.8 +getRemoteIp ()
1.9 +{
1.10 + ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2)
1.11 + ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2)
1.12 + remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}')
1.13 +
1.14 + echo $remote_ip
1.15 +}
1.16 +
1.17 +sendInfoNotification ()
1.18 +{
1.19 + MESSAGE="$1"
1.20 + wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8090/password?msgtype=information&text=$MESSAGE
1.21 +}
1.22 +
1.23 +sendErrorNotification ()
1.24 +{
1.25 + MESSAGE="$1"
1.26 + wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8090/password?msgtype=critical&text=$MESSAGE
1.27 +}
1.28 +
1.29 +
1.30 if [ -r "$BASEDIR/truecrypt_config.cfg" ]
1.31 then
1.32 . "$BASEDIR/truecrypt_config.cfg"
1.33 @@ -21,7 +44,7 @@
1.34 # make sure the device is not mounted (always run the init_manger script here!)
1.35 init_manager.sh "$DEVICE"
1.36
1.37 -
1.38 +sendInfoNotification "Encrypt device"
1.39 if [ -z "$KEYFILE" ]
1.40 then
1.41 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" "$DEVICE")"
1.42 @@ -30,12 +53,16 @@
1.43 message="$($tc_cmd -c --non-interactive --quick --filesystem=none --encryption=AES --hash=RIPEMD-160 -p "$PASSWORD" -k "$KEYFILE" "$DEVICE")"
1.44 result="$?"
1.45 fi
1.46 +
1.47
1.48 if [ "$result" != "0" ]
1.49 then
1.50 + sendErrorNotification "Encryption failed"
1.51 exit 1
1.52 fi
1.53
1.54 +sendInfoNotification "Device encrypted"
1.55 +
1.56
1.57
1.58 if [ -z "$KEYFILE" ]
1.59 @@ -54,7 +81,7 @@
1.60
1.61
1.62
1.63 -
1.64 +sendInfoNotification "Create NTFS filesystem on encrypted device"
1.65
1.66 TC_DEVICE=$(truecrypt -l | awk '{print $3}')
1.67
1.68 @@ -63,10 +90,15 @@
1.69
1.70 if [ "$result" != "0" ]
1.71 then
1.72 + sendErrorNotification "Filesystem creation failed"
1.73 exit 1
1.74 fi
1.75
1.76 +sendInfoNotification "Filesystem successfully created"
1.77 +
1.78 mount "$TC_DEVICE" "$MOUNTPOINT"
1.79
1.80 +sendInfoNotification "Stick is now initialized"
1.81 +
1.82 echo "$message"
1.83 exit 0
1.84 \ No newline at end of file