Skip to content
Snippets Groups Projects
Select Git revision
  • 15bb6b6e93fd0733a9feb877d2091acc3c80fb16
  • experimental default protected
  • v2023.2.5-ffs
  • nrb/ex400-remove-wps
  • nrb/airmax-test
  • v2023.2.4-ffs
  • nrb/ar9344-reset-sequence
  • autinerd/experimental-openwrt-24.10
  • v2023.2.3-ffs
  • v2023.2.2-ffs
  • v2023.2-ffs
  • v2023.1-ffs
  • v2022.1.4-ffs
  • feature/addMikrotikwAP
  • v2022.1.3-ffs
  • v2021.1.2-ffs
  • v2022.1.1-ffs
  • master protected
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • experimental-2025-07-04
  • experimental-2025-07-04-base
  • experimental-2025-07-01
  • experimental-2025-07-01-base
  • experimental-2025-06-25
  • experimental-2025-06-25-base
  • experimental-2025-06-24
  • experimental-2025-06-24-base
  • experimental-2025-06-22
  • experimental-2025-06-22-base
  • v2023.2.5-ffs0.1
  • experimental-2025-06-08
  • experimental-2025-06-08-base
  • experimental-2025-06-06
  • experimental-2025-06-06-base
  • experimental-2025-05-27
  • experimental-2025-05-27-base
  • experimental-2025-05-18
  • experimental-2025-05-18-base
  • experimental-2025-05-15
41 results

image-customization.lua

Blame
  • ap-timer 1.22 KiB
    #!/usr/bin/lua
    local timestamp = os.time()
    local uci = require('simple-uci').cursor()
    
    local function compare(list, value)
      if not list then
        return nil
      end
    
      for _, v in ipairs(list) do
        if v == value then
          return true
        end
      end
    
      return false
    end
    
    local function getDay()
      local type = uci:get('ap-timer', 'settings', 'type')
      if type == 'day' then return 'all'
      elseif type == 'week' then return os.date('%a', timestamp)
      elseif type == 'month' then return os.date('%d', timestamp)
      else return nil
      end
    end
    
    local function apSet(enable)
      local execWifi = false
      local radios = {'client_radio0', 'client_radio1'}
      for _, radio in ipairs(radios) do
        if uci:get('wireless', radio) then
          uci:set('wireless', radio, 'disabled', not enable)
          execWifi = true
        end
      end
    
      if execWifi then
        uci:save('wireless')
        os.execute('wifi')
      end
    end
    
    if uci:get_bool('ap-timer', 'settings', 'enabled') then
      local day = getDay()
      local current = os.date('%H:%M', timestamp)
    
      local off = compare(uci:get_list('ap-timer', day, 'off'), current)
      local on = compare(uci:get_list('ap-timer', day, 'on'), current)
    
      if on and not off then
        apSet(true)
      end
    
      if off and not on then
        apSet(false)
      end
    end