nodemecu/functions

28 lines
621 B
Text
Raw Normal View History

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
ssh-keygen -t ecdsa -f "$private_key" -N "" -C "$@"
2022-03-03 19:34:32 +00:00
}
# Firmar el archivo usando la llave privada.
#
# Uso: sign_file archivo.json
2022-03-12 21:53:48 +00:00
# Devuelve: La firma
sign_file () {
local _file="$1"
test ! -f "$_file" && return 1
2022-03-14 19:23:45 +00:00
test -f "$_file.sig" || ssh-keygen -Y sign -f "$private_key" -n file "$_file" 2>&1 >/dev/null
2022-03-12 21:53:48 +00:00
cat "${_file}.sig" | grep -v SIGNATURE | tr -d "\n"
}