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