diff --git a/config/shell_command.yaml b/config/shell_command.yaml new file mode 100644 index 0000000..9251a17 --- /dev/null +++ b/config/shell_command.yaml @@ -0,0 +1,102 @@ +# =========================================== +# shell_command.yaml +# =========================================== +# SSH-based commands to control OpenWRT router +# +# Prerequisites: +# 1. SSH key generated: /config/.ssh/openwrt_key +# 2. Public key added to router: /root/.ssh/authorized_keys +# 3. Scripts installed on router: /root/scripts/ + +# =========================================== +# Device Blocking Commands +# =========================================== + +# Block device - prevents internet access while allowing local network +block_device: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + '/root/scripts/block_device.sh {{ mac }}' + +# Unblock device - restores internet access +unblock_device: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + '/root/scripts/unblock_device.sh {{ mac }}' + +# Check if device is currently blocked +check_block_status: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + '/root/scripts/check_block_status.sh {{ mac }}' + +# =========================================== +# Bulk Operations +# =========================================== + +# Block multiple devices +block_multiple: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + 'for mac in $(echo "{{ macs }}" | tr "," " "); do /root/scripts/block_device.sh "$mac"; done' + +# Unblock multiple devices +unblock_multiple: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + 'for mac in $(echo "{{ macs }}" | tr "," " "); do /root/scripts/unblock_device.sh "$mac"; done' + +# =========================================== +# Bandwidth Query Commands +# =========================================== + +get_device_bandwidth: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + '/root/scripts/get_bandwidth.sh {{ mac }}' + +# =========================================== +# Device Presence Commands +# =========================================== + +check_device_connected: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + 'cat /tmp/dhcp.leases | grep -i "{{ mac }}" | wc -l' + +get_device_ip: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + 'cat /tmp/dhcp.leases | grep -i "{{ mac }}" | awk "{print \$3}"' + +# =========================================== +# WiFi Signal Strength +# =========================================== + +get_wifi_signal: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 + 'iw dev wlan0 station dump | grep -A 10 "{{ mac }}" | grep "signal:" | awk "{print \$2}"' + +# =========================================== +# Router Management Commands +# =========================================== + +restart_router: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'reboot' + +clear_all_blocks: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'iptables -F FORWARD' + +get_router_uptime: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'uptime' + +get_router_load: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'cat /proc/loadavg' + +# =========================================== +# Diagnostic Commands +# =========================================== + +list_firewall_rules: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'iptables -L FORWARD -n -v' + +list_dhcp_leases: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'cat /tmp/dhcp.leases' + +list_wifi_clients: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 'iw dev wlan0 station dump' + +check_nlbwmon_status: > + ssh -i /config/.ssh/openwrt_key -o StrictHostKeyChecking=no root@10.0.0.254 '/etc/init.d/nlbwmon status'