rasplice2passwd.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. #Rasplice to Password hyperconverged-cloud enabled integration tool
  3. arbitrario="!"
  4. if [[ $1 = "-h" ]] || [[ $1 = "--help" ]]; then
  5. echo "usage: ./rasplice2passwd.sh [OPTIONS]"
  6. echo " "
  7. echo "Option Meaning"
  8. echo "-y accept the default values"
  9. echo " "
  10. echo "if rasplice2passwd is invoked without options it guides you through all the features of your new awesome password"
  11. exit 1
  12. fi
  13. if [ "$1" = "-y" ]
  14. then
  15. sleep 0.1
  16. else
  17. read -p "select minimum word lenght (press ENTER for default = 6): " lenght
  18. read -p "select number for words to integrate (press ENTER for default = 4): " words
  19. read -p "add random text/numbers? (y/n) (press ENTER for default = y):" random
  20. read -p "limit the string to n chars (press ENTER for default = no limit):" limit
  21. fi
  22. lenght=${lenght:-6}
  23. words=${words:-4}
  24. random=${random:-"y"}
  25. limit=${limit:-"n"}
  26. if [ $random = "y" ]; then
  27. randomchars=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
  28. fi
  29. rasplice=$(curl -k -s https://rasplice.contaminati.net/sproloquio.txt | grep -e "[^\ ]\{$lenght,\}" | shuf -n $words | sed 's/^\(.\)/\U\1/' | paste -sd "")
  30. if [ ! -z "$limit" ] && [ ! $limit = "n" ]; then
  31. rasplice=$(echo $rasplice | cut -c1-$limit)
  32. fi
  33. echo ""
  34. echo $rasplice$randomchars$arbitrario