usbmount/mount.d/00_create_model_symlink
changeset 2 ee0797f46473
parent 0 60bc07f3f415
     1.1 --- a/usbmount/mount.d/00_create_model_symlink	Thu Feb 27 17:12:59 2014 +0100
     1.2 +++ b/usbmount/mount.d/00_create_model_symlink	Tue Nov 04 14:58:00 2014 +0100
     1.3 @@ -13,6 +13,23 @@
     1.4  #
     1.5  set -e
     1.6  
     1.7 +log()
     1.8 +{
     1.9 +	if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
    1.10 +		logger -p user.$1 -t "usbmount[$$]" -- "$2"
    1.11 +	fi
    1.12 +}
    1.13 +
    1.14 +getRemoteIp ()
    1.15 +{
    1.16 +	ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2)
    1.17 +	ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2)
    1.18 +	remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}')
    1.19 +
    1.20 +	echo $remote_ip
    1.21 +}
    1.22 +
    1.23 +
    1.24  # Replace spaces with underscores, remove special characters in vendor
    1.25  # and model name.
    1.26  UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    1.27 @@ -34,8 +51,37 @@
    1.28      name="${name}_$partition"
    1.29  fi
    1.30  
    1.31 -mkdir -p "/var/run/usbmount/$name"
    1.32 -osecfs /etc/osecfs/osecfs_usb.cfg /var/run/usbmount/$name ro
    1.33 +set +e
    1.34 +#if [ -f "/media/usb0/opensecurity.tc" ]
    1.35 +#then
    1.36 +#	log info "Found Truecrypt file on Stick. Try to mount"
    1.37 +#	wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8090/password?text=Please+enter+the+password
    1.38 +#	if [ "$?" != "0" ]
    1.39 +#	then
    1.40 +#		log err "ERROR: Connection to http://$(getRemoteIp):8090/password?text=Please+enter+the+password failed"
    1.41 +#		exit 1
    1.42 +#	fi
    1.43 +#
    1.44 +#	log info "Password notification sended, wait for response"
    1.45 +#	mkdir -p "/media/encrypted"
    1.46 +#	/usr/bin/encryptionprovider.py -m eth0 58080 /media/usb0/opensecurity.tc /media/encrypted
    1.47 +#	if [ "$?" != "0" ]
    1.48 +#	then
    1.49 +#		log err "Stick removed. exit"
    1.50 +#		exit 1
    1.51 +#	fi
    1.52 +#	mkdir -p "/var/run/usbmount/encrypted"
    1.53 +#	/usr/bin/osecfs /etc/osecfs/osecfs_usb.cfg "/var/run/usbmount/encrypted" rw
    1.54 +#	log info "Encrypted stick mounted"
    1.55 +#else
    1.56 +#	mkdir -p "/var/run/usbmount/$name"
    1.57 +	chattr -i "/tmp/usbmount"
    1.58 +	mkdir -p "/tmp/usbmount/$name"
    1.59 +	osecfs /etc/osecfs/osecfs_usb.cfg /tmp/usbmount/$name ro
    1.60 +	encryptionprovider.py -i eth0 58081 "$UM_DEVICE" /media/usb0 &
    1.61 +	chattr +i "/tmp/usbmount"
    1.62 +	#run_initlistener.sh $UM_DEVICE &
    1.63 +#fi
    1.64  
    1.65  
    1.66  exit 0