rasplice2passwd/rasplice2passwd.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

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