ft@0: #!/bin/sh ft@0: # This script creates the model name symlink in /var/run/usbmount. ft@0: # Copyright (C) 2005 Martin Dickopp ft@0: # ft@0: # This file is free software; the copyright holder gives unlimited ft@0: # permission to copy and/or distribute it, with or without ft@0: # modifications, as long as this notice is preserved. ft@0: # ft@0: # This file is distributed in the hope that it will be useful, ft@0: # but WITHOUT ANY WARRANTY, to the extent permitted by law; without ft@0: # even the implied warranty of MERCHANTABILITY or FITNESS FOR A ft@0: # PARTICULAR PURPOSE. ft@0: # ft@0: set -e ft@0: ft@2: log() ft@2: { ft@2: if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then ft@2: logger -p user.$1 -t "usbmount[$$]" -- "$2" ft@2: fi ft@2: } ft@2: ft@2: getRemoteIp () ft@2: { ft@2: ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2) ft@2: ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2) ft@2: remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}') ft@2: ft@2: echo $remote_ip ft@2: } ft@2: ft@2: ft@0: # Replace spaces with underscores, remove special characters in vendor ft@0: # and model name. ft@0: UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'` ft@0: UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'` ft@0: ft@0: # Exit if both vendor and model name are empty. ft@0: test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0 ft@0: ft@0: # Build symlink name. ft@0: if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then ft@0: name="${UM_VENDOR}_$UM_MODEL" ft@0: else ft@0: name="$UM_VENDOR$UM_MODEL" ft@0: fi ft@0: ft@0: # Append partition number, if any, to the symlink name. ft@0: partition=`echo "$UM_DEVICE" | sed 's/^.*[^0123456789]\([0123456789]*\)/\1/'` ft@0: if test -n "$partition"; then ft@0: name="${name}_$partition" ft@0: fi ft@0: ft@2: set +e ft@2: #if [ -f "/media/usb0/opensecurity.tc" ] ft@2: #then ft@2: # log info "Found Truecrypt file on Stick. Try to mount" ft@2: # wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8090/password?text=Please+enter+the+password ft@2: # if [ "$?" != "0" ] ft@2: # then ft@2: # log err "ERROR: Connection to http://$(getRemoteIp):8090/password?text=Please+enter+the+password failed" ft@2: # exit 1 ft@2: # fi ft@2: # ft@2: # log info "Password notification sended, wait for response" ft@2: # mkdir -p "/media/encrypted" ft@2: # /usr/bin/encryptionprovider.py -m eth0 58080 /media/usb0/opensecurity.tc /media/encrypted ft@2: # if [ "$?" != "0" ] ft@2: # then ft@2: # log err "Stick removed. exit" ft@2: # exit 1 ft@2: # fi ft@2: # mkdir -p "/var/run/usbmount/encrypted" ft@2: # /usr/bin/osecfs /etc/osecfs/osecfs_usb.cfg "/var/run/usbmount/encrypted" rw ft@2: # log info "Encrypted stick mounted" ft@2: #else ft@2: # mkdir -p "/var/run/usbmount/$name" ft@2: chattr -i "/tmp/usbmount" ft@2: mkdir -p "/tmp/usbmount/$name" ft@2: osecfs /etc/osecfs/osecfs_usb.cfg /tmp/usbmount/$name ro ft@2: encryptionprovider.py -i eth0 58081 "$UM_DEVICE" /media/usb0 & ft@2: chattr +i "/tmp/usbmount" ft@2: #run_initlistener.sh $UM_DEVICE & ft@2: #fi ft@0: ft@0: ft@0: exit 0