1#!/bin/sh
2
3##############################################################
4# NAME
5# fileCopy.sh -- Copy files and folders from CasperShare/Files to end user's hard drive.
6#
7# SCRIPT PARAMETERS
8#
9# $1 - mountPoint $2 - Computer Name $3 - Username
10# -------
11# $4 - Name of the file/directory to copy
12# $5 - Path that you're copying to
13#
14##############################################################
15#
16# VARIABLES & PARAMETERS
17#
18##############################################################
19
20sourceFile=$4
21destPath=$5
22sourcePath="/Volumes/CasperShare/Files"
23
24##############################################################
25#
26# SCRIPT CONTENTS
27#
28##############################################################
29
30# Check to see if source file/folder exists
31if [ ! -f "$sourcePath/$sourceFile" ] && [ ! -d "$sourcePath/$sourceFile" ]; then
32 echo "Error: SOURCE does not exist!";
33 exit 1
34fi
35
36# Check if source folder is a file, else it's a directory
37if [ -f "$sourcePath/$sourceFile" ]; then
38 if [ ! -d "$destPath" ]; then
39 echo "Error: Destination path does not exist!";
40 exit 1
41 fi
42 # Check if file already exists to prevent over-writing.
43 if [ -f "$destPath/$sourceFile" ]; then
44 echo "Error: Destination path already contains FILE "$sourceFile"";
45 exit 1
46 fi
47 echo "Copying FILE "$sourceFile" to "$destPath"";
48 cp "$sourcePath/$sourceFile" "$destPath";
49 chmod 777 "$destPath/$sourceFile";
50else
51 if [ ! -d "$destPath" ]; then
52 echo "Error: Destination path does not exist!";
53 exit 1
54 fi
55 # Check if folder already exists to prevent over-writing.
56 if [ -d "$destPath/$sourceFile" ]; then
57 echo "Error: Destination path already contains DIRECTORY "$sourceFile"";
58 exit 1
59 fi
60 echo "Copying DIRECTORY "$sourceFile" to "$destPath"";
61 cp -R "$sourcePath/$sourceFile" "$destPath";
62 chmod -R 777 "$destPath/$sourceFile";
63fi
64
65exit 0