File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # info: generate api key
3+ # options: none
4+ #
5+ # The function creates a key file in /usr/local/vesta/data/keys/
6+
7+
8+ # ----------------------------------------------------------#
9+ # Variable&Function #
10+ # ----------------------------------------------------------#
11+
12+ keygen ()
13+ {
14+ cat /dev/urandom | tr -dc ' a-zA-Z0-9' | fold -w ${1:- 32} | head -n 1
15+ }
16+ KEYS=' /usr/local/vesta/data/keys/'
17+ HASH=$( keygen)
18+
19+
20+ # ----------------------------------------------------------#
21+ # Action #
22+ # ----------------------------------------------------------#
23+
24+ if [[ -e ${KEYS}${HASH} ]] ; then
25+ while [[ -e ${KEYS}${HASH} ]] ; do
26+ HASH=$( keygen)
27+ done
28+ fi
29+
30+ touch ${KEYS}${HASH}
31+ echo ${HASH}
32+
33+ # ----------------------------------------------------------#
34+ # Vesta #
35+ # ----------------------------------------------------------#
36+
37+ exit
You can’t perform that action at this time.
0 commit comments