-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2fatores.sh
executable file
·62 lines (48 loc) · 1.25 KB
/
2fatores.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -e
#################################### Variáveis
export SOURCE="${HOME}/.2FA_Store"
#################################### Teste
# gpg = Criptografia Simétrica
# oathtools = Gerar senhas 2FA
for check in 'gpg' 'oathtools'; do
if ! which "$check" &>/dev/null; then
echo "Necessita do software $check instalado"
exit 1
fi
done
#################################### Funções
function start()
{
if [[ ! -d "$SOURCE" ]];then
mkdir -v "$SOURCE"
chmod 0700 "$SOURCE"
fi
}
function die()
{
echo "$@"
exit 1
}
function newKey() # Adiciona uma nova chave
{
if [[ -n "$1" ]]; then
local service="$1"
else
read -ep "Qual o nome do serviço? " service
[[ -z "$service" ]] && die "Necessita do nome do serviço"
fi
read -ep "Chave secreta do serviço ${service}: " secretKey
[[ -z "$service" ]] && die "Necessita do nome do serviço"
gpg --quit ----symmetric --out ${SOURCE}/${service} <<< "$secretKey"
}
#################################### Início
start
# 1. Adicionar uma nova chave
# 2. Gerar uma nova senha
# 3. Listar o serviços disponíveis
case $1 in
--new|-n) newKey "$2" ;;
--totp|-t) : ;;
--list|-l) : ;;
esac