#!/bin/bash

bootstrap () 
{

	files1mounted=`mount | grep files1`

	if [[ $files1mounted != NULL ]]; then

	files1username=`echo $files1mounted | cut -d "/" -f 4 | cut -d " " -f 1`;
	files1mountpoint=`echo $files1mounted | cut -d " " -f 3`;

	echo $files1username;
	echo $files1mountpoint;

	else

	open "smb://files1.4j.lane.edu";
	
	bootstrap

	fi;

}

bootstrap;

if [[ ! -d "$files1mountpoint/public_html" ]]; then
	if  [[ -d "$files1mountpoint/WWWpublic_html" ]]; then
		mv "$files1mountpoint/WWWpublic_html" "$files1mountpoint/public_html"
	else
		mkdir "$files1mountpoint/public_html"
		chmod a+r "$files1mountpoint/public_html"
	fi
	if  [[ ! -d "$files1mountpoint/public_html/qr" ]]; then
		mkdir "$files1mountpoint/public_html/qr"
		chmod a+r "$files1mountpoint/public_html/qr"
	fi
fi

cp "$1" "$files1mountpoint/public_html/qr/"

basename=$(basename "$1")
echo "$basename"

open "http://staff.4j.lane.edu/~nelson_d/qr/singlefile/?user=nelson_d&folder=$basename&Submit=Get+Codes"

exit 0;