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-03 19:34:32 +00:00
|
|
|
ssh-keygen -t ecdsa -f "$private_key" -N "" -m PEM
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
if ! openssl dgst -sha512 -sign "$private_key" "$_file" | base64 | tr -d "\n" > "$_file.sign" ; then
|
|
|
|
rm -f "$_file.sign"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$_file.sign"
|
|
|
|
}
|