Advertisement
Guest User

letitbitUploader.sh

a guest
Jul 4th, 2014
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.26 KB | None | 0 0
  1. #!/bin/bash
  2. # Bash Uploader For Letitbit
  3. # Version 2.0140617
  4. version="2.0140617";
  5. # /usr/local/bin/letitbitUploader.sh
  6. # Dependencies:
  7. #   1. plowshare script: https://code.google.com/p/plowshare/wiki/Contributions
  8. # Scope:
  9. #   1. Randomly scrambles the checksum hash values of all files in current directory
  10. #   2. Uploads all files in a directory to an account on Letitbit
  11. ####################################################################################################
  12. #                                      CONFIGURATION SETTINGS                                      #
  13. ####################################################################################################
  14. # Configure the following with your credentials between the ' ' marks.
  15. user='';
  16. pass='';
  17. ####################################################################################################
  18. #                                              SCRIPT                                              #
  19. ####################################################################################################
  20. echo "##################################################";
  21. echo "#   Bash File Upload For Letitbit v"$version"   #";
  22. echo "##################################################";
  23. ####################################################################################################
  24. green=$(tput setaf 2); yellow=$(tput setaf 3); red=$(tput setaf 1); cyan=$(tput setaf 6); textreset=$(tput sgr0); STARTTIME=$(date +%s);
  25. #Uploads the files
  26. rm -f .Letitbit.swp LetitbitLinks.txt 2>/dev/null; touch .Letitbit.swp 2>/dev/null;
  27. for file in ./*; do
  28.   fileExtension=`ls $file | cut -c3-`;
  29.   fileName=`ls $file | sed 's/\.\///'`;
  30.   if [[ $fileExtension == *.txt ]] || [[ $fileExtension == *.png ]] || [[ $fileExtension == *.jpeg ]] || [[ $fileExtension == *.jpg ]]; then
  31.     echo $yellow"Skipping:"${textreset};
  32.     echo $yellow"$fileName"${textreset};
  33.     echo $cyan"***************************************************************"${textreset};
  34.   fi;
  35.   if [[ $fileExtension != *.txt ]] && [[ $fileExtension != *.png ]] && [[ $fileExtension != *.jpeg ]] && [[ $fileExtension != *.jpg ]]; then
  36.     echo $cyan"***************************************************************"${textreset};
  37.     echo $yellow"Uploading "$fileName"..."${textreset};
  38.     plowup -q -r 3 -a $user":"$pass Letitbit $file > .Letitbit.swp;
  39.     uploadLink=`cat .Letitbit.swp | grep -v "^\#DEL\ " | tr -d '\n' | tr -d '\ ';`;
  40.     uploadedFileSize=`ls -lh $file | awk {'print $5'}`;
  41.     echo "[B]Letitbit: [/B][URL="$uploadLink"]"$fileName" - "$uploadedFileSize"B[/URL]" >> LetitbitLinks.txt
  42.     echo $green$fileName" successfully uploaded!"${textreset};
  43.     echo $green$uploadLink${textreset};
  44.     rm .Letitbit.swp 2>/dev/null;
  45.   fi;
  46. done;
  47.  
  48. sed -i '/\[B\]Letitbit\:\ \[\/B\]\[URL\=\]/d' LetitbitLinks.txt;
  49. cat LetitbitLinks.txt
  50. #Counts the number of links generated and display with number of files in current directory.
  51. numFiles=`ls ./* | grep -v \.txt$ | grep -v \.png$ | grep -v \.jpg$ | grep -v \.jpeg$ | wc -l`;
  52. numLinks=`cat LetitbitLinks.txt | wc -l`; ENDTIME=$(date +%s);
  53. echo "Number of files in this directory: "$numFiles;
  54. echo "Total # Letitbit URLs generated: "$numLinks;
  55. echo "Number of seconds this script ran for: "$(($ENDTIME - $STARTTIME));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement