Commit c96f05ec authored by Carlos Remuzzi's avatar Carlos Remuzzi
Browse files

implementando parser de argumentos

parent 7f2dc675
#!/usr/bin/env bash #!/usr/bin/env bash
AP_ADDRESS=192.168.12.1 valid_ip() {
# legacy, porque hemos empezado con la sala llamada libreCast-s1 local ip=$1
if [ $# -eq 1 ];then local stat=1
AP_ADDRESS=$1
fi if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
if [ $# -eq 2 ];then IFS='.'
AP_NAME=$2 ip=($ip)
fi IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
invocar_nmcli() { invocar_nmcli() {
echo "conectando a $AP_NAME" echo "conectando a $AP_NAME"
...@@ -89,4 +95,20 @@ main() { ...@@ -89,4 +95,20 @@ main() {
fi fi
} }
# por defecto apuntamos a la ip predefinida del AP wifi
AP_ADDRESS=192.168.12.1
if [ $# -eq 1 ];then
if valid_ip $1;then
AP_ADDRESS=$1
else
AP_NAME=$1
fi
fi
if [ $# -eq 2 ];then
AP_ADDRESS=$1
AP_NAME=$2
fi
main main
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment