usbmount/mount.d/00_create_model_symlink
author ft
Tue, 04 Nov 2014 14:58:00 +0100
changeset 2 ee0797f46473
parent 0 60bc07f3f415
permissions -rwxr-xr-x
changed some things
     1 #!/bin/sh
     2 # This script creates the model name symlink in /var/run/usbmount.
     3 # Copyright (C) 2005 Martin Dickopp
     4 #
     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.
     8 #
     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
    12 # PARTICULAR PURPOSE.
    13 #
    14 set -e
    15 
    16 log()
    17 {
    18 	if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
    19 		logger -p user.$1 -t "usbmount[$$]" -- "$2"
    20 	fi
    21 }
    22 
    23 getRemoteIp ()
    24 {
    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}')
    28 
    29 	echo $remote_ip
    30 }
    31 
    32 
    33 # Replace spaces with underscores, remove special characters in vendor
    34 # and model name.
    35 UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    36 UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    37 
    38 # Exit if both vendor and model name are empty.
    39 test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0
    40 
    41 # Build symlink name.
    42 if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then
    43     name="${UM_VENDOR}_$UM_MODEL"
    44 else
    45     name="$UM_VENDOR$UM_MODEL"
    46 fi
    47 
    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"
    52 fi
    53 
    54 set +e
    55 #if [ -f "/media/usb0/opensecurity.tc" ]
    56 #then
    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
    59 #	if [ "$?" != "0" ]
    60 #	then
    61 #		log err "ERROR: Connection to http://$(getRemoteIp):8090/password?text=Please+enter+the+password failed"
    62 #		exit 1
    63 #	fi
    64 #
    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
    68 #	if [ "$?" != "0" ]
    69 #	then
    70 #		log err "Stick removed. exit"
    71 #		exit 1
    72 #	fi
    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"
    76 #else
    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 &
    84 #fi
    85 
    86 
    87 exit 0