What's new

cfgmnt-sender - Send decoded event to the cfg_server

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

cyruz

Occasional Visitor
Hi guys,

following my findings on this thread, I created a script to send event strings to the cfg_server. Part of these strings are related to some of the features available in the web interface.

You need to install socat to use thescript: opkg update && opkg install socat

Right now, I only decoded the Reboot event. Please feel free to add any other event to the script.

Decoded Events:
  • Reboot (mesh)

Script:

Code:
# cfgmnt-sender
# -------------
# Send event to IPC socket of the cfg_server running on the router.
# Require socat.
# The events have to be decoded first. Decoded commands:
#   * REBOOT: "{\"httpd\":{\"eid\":\"9\",\"mac_list\":[\"xx:xx:xx:xx:xx:xx\"],\"data\":\"{}\"}}"
#     Require a mac-address list of the mesh devices to be rebooted.
# -------------

cmd_reboot() {
    CMD_REBOOT_PFX="{\"httpd\":{\"eid\":\"9\",\"mac_list\":[\""
    CMD_REBOOT_SFX="\"],\"data\":\"{}\"}}"
  
    case $1 in
        -h|--help|help)
            echo "cfgmnt-sender reboot <comma separated mac-address list>"
            echo "Eg: cfgmng-sender reboot xx:xx:xx:xx:xx:xx,yy:yy:yy:yy:yy:yy"
            ;;
        *)
            [ -n "$1" ] && [ -z "`echo "$1" | sed -E "s/[0-9a-fA-F:]{17}(,[0-9a-fA-F:]{17})*//"`" ] \
            && SEND=1 || echo "Unknown/missing parameter, use 'reboot help' for info."
            ;;
    esac

    [ -n "$SEND" ] && __send "$CMD_REBOOT_PFX$1$CMD_REBOOT_SFX"
}


__send() {
   echo "cfgmnt-sender :: sending <$@> to 'var/run/cfgmnt_ipc_socket'"
   echo "$@" | socat - unix-connect:/var/run/cfgmnt_ipc_socket
}


# Check for socat presence.
[ -z "`opkg status socat | grep 'Status'`" ] && echo "ERROR :: socat not installed." && exit 1

case $1 in
    -h|--help|help)
        echo "cfgmnt-sender <command> <parameters|help>"
        echo "Available commands: reboot"
        ;;
    *)
        type "cmd_$1" | grep -qwi function && RUN=1 || echo "Unknown command, use 'help' for info."
        ;;
esac

[ -n "$RUN" ] && "cmd_$@"
 
Last edited:

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top