mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-22 21:40:20 -08:00
43 lines
1018 B
Bash
Executable File
43 lines
1018 B
Bash
Executable File
#!/bin/bash
|
|
# info: generate api key
|
|
# options: none
|
|
#
|
|
# The function creates a key file in /usr/local/vesta/data/keys/
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
keygen()
|
|
{
|
|
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
|
|
}
|
|
KEYS='/usr/local/vesta/data/keys/'
|
|
HASH=$(keygen)
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
if [ ! -d ${KEYS} ]; then
|
|
mkdir ${KEYS}
|
|
chmod 0770 ${KEYS}
|
|
fi
|
|
|
|
if [[ -e ${KEYS}${HASH} ]] ; then
|
|
while [[ -e ${KEYS}${HASH} ]] ; do
|
|
HASH=$(keygen)
|
|
done
|
|
fi
|
|
|
|
touch ${KEYS}${HASH}
|
|
echo ${HASH}
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|