Skip to content
Snippets Groups Projects
Commit 460a4f5b authored by nimrod's avatar nimrod
Browse files

Better error handling.

parent 805f64d0
Branches
No related tags found
No related merge requests found
#!/bin/sh -e
. "$1"
if [ -z "$path" ]
then
echo "failed=True msg=Path not set."
fail ()
{
echo "{\"failed\": true, \"msg\": \"$1\"}"
exit
fi
}
if [ ! -r $path ]
then
echo "failed=True msg=Can\'t access path."
exit
fi
if [ ! -f $path ]
then
echo "failed=True msg=Path doesn't exist or is not a file."
exit
fi
test -z "$path" && fail "Parameter 'path' is not set."
test ! -r "$path" && fail "Can't access 'path'."
test ! -f "$path" && fail "Parameter 'path' doesn't exists or is not a file."
bits="$(openssl dhparam -in $path -text -noout \
| sed -n 's/[a-zA-Z#0-9 \-]*Parameters: (\([0-9]*\) bit)/\1/p')"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment