2022-02-23 14:42:32 +00:00
|
|
|
get_stack () {
|
|
|
|
if [[ ! -z $1 && $1 == "wc" ]];then
|
|
|
|
ls /opt/nodemecu/stack | wc -l
|
|
|
|
else
|
|
|
|
ls /opt/nodemecu/stack | tail -1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-03 19:34:32 +00:00
|
|
|
# Generar una llave privada ECDSA si no existe
|
|
|
|
generate_private_key () {
|
|
|
|
test -f "$private_key" && return 1
|
2022-02-23 14:42:32 +00:00
|
|
|
|
2022-03-12 21:51:29 +00:00
|
|
|
ssh-keygen -t ecdsa -f "$private_key" -N "" -C "$@"
|
2022-03-03 19:34:32 +00:00
|
|
|
}
|
2022-03-03 19:34:47 +00:00
|
|
|
|
|
|
|
# Firmar el archivo usando la llave privada.
|
|
|
|
#
|
|
|
|
# Uso: sign_file archivo.json
|
|
|
|
# Devuelve: archivo.json.sign
|
|
|
|
sign_file () {
|
|
|
|
local _file="$1"
|
|
|
|
|
|
|
|
test ! -f "$_file" && return 1
|
2022-03-12 21:51:52 +00:00
|
|
|
if test -f "$_file.sig" ; then
|
|
|
|
echo "$_file.sig"
|
|
|
|
return 0
|
2022-03-03 19:34:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-12 21:51:52 +00:00
|
|
|
LC_ALL=C ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file "$_file" 2>&1| grep Write | cut -d " " -f 4
|
2022-03-03 19:34:47 +00:00
|
|
|
}
|