Advertisement
lachiu

Script

Nov 25th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Variables
  4. dir="/home/name"
  5. dir_Plex="/home/name/Plex/*"
  6. dir_du=$(du -s $dir | cut -f1)
  7. txt="/mnt/logs/name-share-size.txt"
  8. qck_math=$(($dir_du/1048576))
  9. qck_maths=$qck_math"GB"
  10.  
  11. # ===============================================
  12. #
  13. # Color
  14.  
  15. lb=`echo -e "\e[94m"`
  16. rd=`echo -e "\e[31m"`
  17. clr=`echo -e "\e[0m"`
  18.  
  19. # ==============================================
  20. #
  21. # ifs
  22.  
  23. if [ $qck_math -ge "100" ]; then
  24.         math_color=$rd
  25.         chmod -w $dir_Plex
  26.         txt3="Removing write permissions now."
  27. else
  28.         math_color=$lb
  29.         chmod +w $dir_Plex
  30.         txt3="Granting write permissions now."
  31. fi
  32.  
  33. # or this supposedly
  34. # [ $qck_math -ge "100" ] && math_color=$rd && chmod -w $dir_Plex || math_color=$lb &^ chmod +w $dir_Plex
  35.  
  36. # ===============================================
  37. #
  38. # Computer speaking:
  39. # txt1
  40. echo "" >> $txt
  41. date=$lb$(date +%D)$clr" - "$lb$(date +%H"u"%M"m"%S"s")$clr
  42. echo "$date - $lb"Computer"$clr: Checking the folder size now." >> $txt
  43.  
  44. # txt2
  45. date=$lb$(date +%D)$clr" - "$lb$(date +%H"u"%M"m"%S"s")$clr
  46. echo "$date - $lb"Computer"$clr: $lb$dir$clr is $math_color$qck_maths$clr." >> $txt
  47.  
  48.  
  49. # txt3
  50. date=$lb$(date +%D)$clr" - "$lb$(date +%H"u"%M"m"%S"s")$clr
  51. echo "$date - $lb"Computer"$clr: $txt3" >> $txt
  52.                                                                                                                                                                 27,1          Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement