{"id":15917548,"url":"https://github.com/takuya/openwrt-uci-dhcp-sort","last_synced_at":"2025-04-03T11:41:55.241Z","repository":{"id":136551205,"uuid":"601209001","full_name":"takuya/openwrt-uci-dhcp-sort","owner":"takuya","description":"sort openwrt dhcp hosts","archived":false,"fork":false,"pushed_at":"2024-01-06T14:27:44.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T01:14:04.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-13T15:38:05.000Z","updated_at":"2023-02-13T15:51:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e7ee9fc-ca66-4ea1-a445-ba8cb2e20761","html_url":"https://github.com/takuya/openwrt-uci-dhcp-sort","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"0088eb30ba38ed7e675e9574a0cdb1c08b22278a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fopenwrt-uci-dhcp-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fopenwrt-uci-dhcp-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fopenwrt-uci-dhcp-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fopenwrt-uci-dhcp-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuya","download_url":"https://codeload.github.com/takuya/openwrt-uci-dhcp-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246998102,"owners_count":20866690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T18:11:23.085Z","updated_at":"2025-04-03T11:41:55.220Z","avatar_url":"https://github.com/takuya.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openwrt / sort uci static DHCP v4 lease.\n\nSort openwrt dhcp-static-lease-hosts.\n\nNo v6 available.\nif your uci have a v6 static lease dhcp , this script will disrupt dhcp.host.\n\n# how to use \n\nCopy file into OpenWrt.  Run by Lua\n\n### command\nssh into wrt do this\n```\nlua uci-sort-dhcp-hosts.lua\n```\n\n\n# what does this script do.\n\n- Backup dhcp.@host to /tmp.\n- Get list `uci show dhcp` and eval dhcp.@host to lua.\n- Sort dhcp.hosts by ip addr.\n- Remove all exists by `uci del dhcp.host..`.\n- Add sorted by `uci add dhcp.host `.\n- And commit by executing `uci commit dhcp`.\n\n# how to sort ip address \n\nSort ip as interger by casting ipv4 to Int.\n\n# uci dhcp sample \n\nModifying uci dhcp.hosts samples.\n\n\n```sh\n\n### get current dhcp hosts\nuci show dhcp\n\n### revert changes \nuci revert dhcp \n\n### commit dhcp\nuci commit dhcp \n\n### remove all exist dhcp.hosts\nwhile uci del dhcp.@host[-1] ; do : ;  done;\n\n### add a new dhcp.host\nuci add dhcp host\nuci set dhcp.@host[-1].dns='1'\nuci set dhcp.@host[-1].mac='dc:a6:32:dd:23:c6'\nuci set dhcp.@host[-1].ip='192.168.1.22'\nuci set dhcp.@host[-1].leasetime='86400'\nuci set dhcp.@host[-1].name='raspi-ubuntu'\n\n```\n\n# uci show dhcp via ssh \n\nif you are using ruby or python or JavaScript(node), you can rewrie via ssh.\n\n### sample\n\nIn your favorite language. you can do like this.\n\nJS/python\n```\nssh root@192.168.1.1 'uci show dhcp' \\\n  | \\grep dhcp.@host | sed -E 's/@//' | sed -E 's/=host/={}/' \u003e\u003e dhcp.js\n```\n\nruby\n```\nssh root@192.168.1.1 'uci show dhcp' \\\n  | \\grep dhcp.@host | sed -E 's/@//' | sed -E 's/=host/=OpenStruct.new/' \u003e\u003e dhcp.rb\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fopenwrt-uci-dhcp-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuya%2Fopenwrt-uci-dhcp-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fopenwrt-uci-dhcp-sort/lists"}