Adding experimentation shell scripts !
This commit is contained in:
parent
29d5a48440
commit
4489f22ac0
90
scripts/experiment/luciRpc.sh
Normal file
90
scripts/experiment/luciRpc.sh
Normal file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
function rpcLogin() {
|
||||
local IP=$1
|
||||
local PORT=$2
|
||||
local USER="$3"
|
||||
local PASS="$4"
|
||||
local RES=""
|
||||
|
||||
local cmd="curl"
|
||||
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/auth"
|
||||
local opt="--silent --data"
|
||||
local data="{ \"id\": 1, \"method\": \"login\", \"params\": [ \"$USER\", \"$PASS\" ] }"
|
||||
|
||||
res=$(${cmd} ${url} ${opt} "${data}")
|
||||
echo ${res} | jq -Ma ".result"
|
||||
}
|
||||
|
||||
function iwList()
|
||||
{
|
||||
local IP=$1
|
||||
local PORT=$2
|
||||
local IFACE=$3
|
||||
local TOKEN="$4"
|
||||
|
||||
local cmd="curl"
|
||||
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
|
||||
local opt="--silent --cookie sysauth=${TOKEN} --data"
|
||||
local data="{ \"method\": \"wifi.getiwinfo\", \"params\": [ \"${IFACE}\" ] }"
|
||||
|
||||
res=$(${cmd} ${url} ${opt} "${data}")
|
||||
echo ${res} |jq
|
||||
}
|
||||
|
||||
function netDeviceInfo()
|
||||
{
|
||||
local IP=$1
|
||||
local PORT=$2
|
||||
local TOKEN="$3"
|
||||
|
||||
local cmd="curl"
|
||||
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
|
||||
local opt="--silent --cookie sysauth=${TOKEN} --data"
|
||||
local data="{ \"method\": \"net.deviceinfo\", \"params\": [ \"wlan0\" ]}"
|
||||
|
||||
res=$(${cmd} ${url} ${opt} "${data}")
|
||||
echo ${res} |jq
|
||||
|
||||
}
|
||||
|
||||
function netDevices()
|
||||
{
|
||||
local IP=$1
|
||||
local PORT=$2
|
||||
local TOKEN="$3"
|
||||
|
||||
local cmd="curl"
|
||||
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
|
||||
local opt="--silent --cookie sysauth=${TOKEN} --data"
|
||||
local data="{ \"method\": \"net.devices\", \"params\": [] }"
|
||||
|
||||
res=$(${cmd} ${url} ${opt} "${data}")
|
||||
echo ${res} |jq
|
||||
}
|
||||
|
||||
function arpTable()
|
||||
{
|
||||
local IP=$1
|
||||
local PORT=$2
|
||||
local TOKEN="$3"
|
||||
|
||||
local cmd="curl"
|
||||
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
|
||||
local opt="--silent --cookie sysauth=${TOKEN} --data"
|
||||
local data="{ \"method\": \"net.arptable\", \"params\": [] }"
|
||||
|
||||
res=$(${cmd} ${url} ${opt} "${data}")
|
||||
echo ${res} |jq
|
||||
}
|
||||
|
||||
#FIXME USER PASS
|
||||
authToken=$(rpcLogin 192.168.1.1 8080 root 'XXXXXX EDITE MOI')
|
||||
|
||||
#netDevices 192.168.1.1 8080 ${authToken}
|
||||
#netDeviceInfo 192.168.1.1 8080 ${authToken}
|
||||
#iwList 192.168.1.1 8080 wlan0 ${authToken}
|
||||
#iwList 192.168.1.1 8080 wlan1 ${authToken}
|
||||
|
||||
adoles:
|
||||
|
26
scripts/experiment/uciCli.sh
Normal file
26
scripts/experiment/uciCli.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
function scanWifi()
|
||||
{
|
||||
local ifcace=$1
|
||||
iwconfig ${iface} scan
|
||||
}
|
||||
|
||||
function connectBoard()
|
||||
{
|
||||
uci delete wireless.@wifi-iface[1]
|
||||
uci add wireless wifi-iface
|
||||
uci set wireless.@wifi-iface[1].network="EmlidReach"
|
||||
uci set wireless.@wifi-iface[1].ssid="Base1:2a:03"
|
||||
uci set wireless.@wifi-iface[1].encryption="psk2"
|
||||
uci set wireless.@wifi-iface[1].device="radio1"
|
||||
uci set wireless.@wifi-iface[1].mode="sta"
|
||||
uci set wireless.@wifi-iface[1].bssid="FC:DB:B3:7E:2A:03"
|
||||
uci set wireless.@wifi-iface[1].key="basepyxis"
|
||||
uci commit
|
||||
reload_config
|
||||
sleep 15
|
||||
udhcpc -i wlan1
|
||||
}
|
||||
|
||||
cells=$(scanWifi wlan1)
|
Reference in New Issue
Block a user