64 lines
1.9 KiB
Bash
Executable File
64 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
USER="lucas"
|
|
DEST="~/Downloads"
|
|
|
|
get_config() {
|
|
while [[ ${1:0:1} == - ]]; do
|
|
echo "Param: $1"
|
|
[[ $1 == -h ]] && {
|
|
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
|
HOST="$2"
|
|
shift 2;
|
|
continue;
|
|
};
|
|
[[ $1 == -f ]] && {
|
|
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
|
file="$2"
|
|
shift 2;
|
|
continue;
|
|
};
|
|
[[ $1 == -o ]] && {
|
|
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
|
opt="$2"
|
|
shift 2;
|
|
continue;
|
|
};
|
|
[[ $1 == -d ]] && {
|
|
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
|
DEST="$2"
|
|
shift 2;
|
|
continue;
|
|
};
|
|
[[ $1 == -p ]] && {
|
|
DEST="~/Videos/.stuff"
|
|
shift 1;
|
|
continue;
|
|
};
|
|
[[ $1 == --help ]] && {
|
|
usage
|
|
exit
|
|
};
|
|
echo "Parameter $1 discarded"
|
|
usage
|
|
exit
|
|
done
|
|
}
|
|
usage() {
|
|
printf "Usage:
|
|
-h <hostname>\tRemote Hostname
|
|
-f <filename>\tPath of local file
|
|
-o <options>\tGive additional Options
|
|
-d <dest>\tChoose other Destination Folder
|
|
-p\t\tChange Destination
|
|
--help\t\tDisplay Usage\n"
|
|
exit
|
|
}
|
|
get_config "$@"
|
|
if [ "${HOST}" == "deluge" ]; then
|
|
HOST="serverhost"
|
|
USER="deluge-user"
|
|
DEST="/home/deluge-user/Downloads/Torrents/"
|
|
fi
|
|
echo "Copy ${file} to ${HOST}:${DEST}"
|
|
scp -r ${opt} "${file}" ${USER}@${HOST}:${DEST}
|