X-Git-Url: https://git.llucax.com/z.facultad/75.08/llamadas.git/blobdiff_plain/81b4fa7c80c2ad49755573fa4d5ca50213e3ce32..fbda2151a8f5f6e2e7fdf5b1d63a38b57fbac262:/inst/util.sh diff --git a/inst/util.sh b/inst/util.sh index 826ab9e..2c159f5 100755 --- a/inst/util.sh +++ b/inst/util.sh @@ -1,5 +1,8 @@ #/bin/sh +BASE_DIR="$HOME/.antifraude" +LOCK_DIR="$BASE_DIR/lock" + # Lee del teclado un valor # # parĂ¡metros : @@ -57,25 +60,38 @@ lock () { echo "No" return fi - echo "lero lero" > "$INST_DIR/lock/$1.pid" + echo "$$" > "$LOCK_DIR/$1.pid" } # Desbloquea el script unlock () { - rm -rf "$INST_DIR/lock/$1.pid" + rm -rf "$LOCK_DIR/$1.pid" } # Consulta si un script esta lockeado is_lock () { - if [ -e "$INST_DIR/lock/$1.pid" ] ; then + if [ -e "$LOCK_DIR/$1.pid" ] ; then # Lock file encontrado! return 0 fi # No hay lock file! return 1 } - + +# Verifica que un valor este entre otros 2 .... $1 pertecezca a [$2,$3] +# $1 Numero a validar +# $2 Cota inferior +# $3 Cota superior + +validar_rango(){ + if [ "$1" -ge "$2" ] && [ "$1" -le "$3" ]; then + return 0 + else + return 1 + fi +} + #leer "Ingrese un directorio" "/tmp" ALGO #echo "Ingresaste : $ALGO"