#!/bin/sh . /usr/share/libubox/jshn.sh . /lib/config/uci.sh # get all enabled radio names to start clone on get_radios_for_wps_clone() { local radio for radio in wifi0 wifi1; do [ -n "$(uci_get wireless $radio)" ] && [ $(uci_get wireless $radio disabled 0) -eq 0 ] && echo $radio done } start_wps_clone() { local global_pid="/var/run/wpa_supplicant-global.pid" local global_ctrl="/var/run/wpa_supplicantglobal" local radio='' json_init uci_get_state wireless wps_clone > /dev/null || uci_set_state wireless wps_clone "" wps_clone if [ "$(uci_get_state wireless wps_clone state)" != "running" ]; then local radios=$(get_radios_for_wps_clone) if [ -z "$radios" ]; then json_add_string "status" "failed: no radio activated" json_dump return 1 fi local uuid="87654321-9abc-def0-1234-$(tr -d : < /sys/class/net/eth0/address)" for radio in $radios; do local interface= # note: adding the same json_property again overrides the former case "$radio" in wifi0) interface=athClone0 json_add_string "status" "Ok" json_add_string "frequency" "2.4G" ;; wifi1) interface=athClone1 json_add_string "status" "Ok" json_add_string "frequency" "5G" ;; *) json_add_string "status" "Failed: no radio activated" json_add_string "reason" "No radio activated" json_dump return 1 ;; esac interface=$(wlanconfig $interface create wlandev $radio wlanmode sta) local ctrl_socket="/var/run/wpa_supplicant-$interface" cat > /var/run/wpa_supplicant-$interface.conf < /dev/null touch /var/run/wpa_supplicant-$interface.lock wpa_cli -i $interface -p $ctrl_socket wps_pbc > /dev/null wpa_cli -p $ctrl_socket -a /usr/libexec/delos/delos-clone-mode-uci -P /var/run/wpa_supplicant-$interface.pid -B > /dev/null done /usr/sbin/updateled.sh > /dev/null 2>/dev/null /dev/null); do local radio=$(cat $ifpath/parent) local interface=$(basename $ifpath) local ctrl_socket="/var/run/wpa_supplicant-$interface" wpa_cli -i $interface -p $ctrl_socket > /dev/null json_add_string status "restarted" case $radio in wifi0) json_add_string frequency "2.4G" ;; wifi1) json_add_string frequency "5G" ;; esac done fi json_dump }