#!/bin/sh

. /lib/functions.sh
. /lib/netifd/netifd-proto.sh
. /usr/share/libubox/jshn.sh

local usb

#get level
level=$(uci get cibersecurityd.cibersecurity.level)

case "$1" in
	list)
                echo '{ "get_configuration": { }, "set_configuration": { } }'
	;;
	call)
		case "$2" in
                        get_configuration)
                                logger "cibersecurityd get_configuration level $level"
				# return json object or an array
                                echo "{ \"level\" :\"$level\" }"
			;;
                        set_configuration)
                                read input;
                                json init
                                json_load "$input"
                                json_get_var level level
                                case $level in
                                "normal"|"secure"|"advanced")
                                    logger "cibersecurityd set_configuration level $level"
                                    uci set cibersecurityd.cibersecurity.level=$level
                                    uci commit cibersecurityd

                                    #all exec stuff
                                    cibersecurity.sh $level

                                    # return json object or an array
                                    echo "{ \"level\" :\"$level\" }"
                                ;;
                                *)
                                level=$(uci get cibersecurityd.cibersecurity.level)
                                # return json object or an array
                                echo "{ \"level\" :\"$level\" }"
                                ;;
                                esac

                        ;;
		esac
	;;
esac

