Files
Server-scripts/serverhost/torrenttransfer.sh
T
2026-09-14 12:43:38 +02:00

76 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
duser="sudo /home/lucas/scripts/deluge_user_cmd.sh"
FILE_PATH="/torrent/complete/"
STUFF="/home/lucas/Documents/Dokumente/Projekte/Server/Transfer/"
ASSUMEYES=false
usage() {
printf "Usage:
-y\ty Mode
-m\tMega Mode
-help\tDisplay this\n"
}
get_config() {
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -help ]] && {
echo "Help true"
usage;
exit;
};
[[ $1 == -y ]] && {
echo "y Mode"
ASSUMEYES=true
shift 1
continue
};
echo "Parameter $1 discarded"
usage
exit
done
}
get_config "$@"
syncNC
IFS=$'\n'; set -f
LIST=($(ls ${FILE_PATH}))
if [ ${#LIST[@]} -eq 0 ]; then
echo "Nothing to Copy/Delete"
exit
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Copy? (y/*)"
echo "${LIST[@]}"
read -n 10 ans
else
ans="y"
fi
fail=false
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
cp -r ${FILE_PATH}${files} ${STUFF}
if [ $? -ne 0 ]; then fail=true; echo "Copy Failure"; exit; fi
chmod 777 -R ${STUFF}${files}
done
printf "Torrents Copied\n"
else
printf "Nothing Copied\n"
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Delete? (y/*)"
echo "${LIST[*]}"
read -n 10 ans
else
ans="y"
fi
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
echo "Delete $files"
sudo /home/lucas/scripts/deluge_user_cmd.sh rm -dr ${FILE_PATH}${files}
done
printf "Torrents Removed\n"
else
printf "Nothing Removed\n"
fi
syncNC >> /dev/null 2>&1