aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/functions
Commit message (Collapse)AuthorAgeFilesLines
* base-files: fix uci led oneshot/timer triggerRobinson Wu2019-06-201-0/+1
| | | | | | | | | | | | | This patch adds a missing type property. This fixes the creation of oneshot and timer led triggers like: | ucidef_set_led_timer "system" "system" "zhuotk:green:system" "1000" "1000" from /etc/init.d/01_leds. Fixes: b06a286a4861 ("base-files: cleanup led functions in uci-defaults.sh") Signed-off-by: Robinson Wu <wurobinson@qq.com> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: add support for the new ar8xxx MIB counters settingsPetr Štetiar2019-05-201-0/+13
| | | | | | | | | | | | | Commit "generic: ar8216: add mib_poll_interval switch attribute" has added mib_poll_interval global config option and commit "generic: ar8216: group MIB counters and use two basic ones only by default" has added mib_type config option. So this patch adds ucidef_set_ar8xxx_switch_mib helper function which would allow configuration of the above mentioned new switch config options. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* base-files: add leds migrationTomasz Maciej Nowak2019-04-061-0/+39
| | | | | | | | | | | Currently leds migration scripts in ar71xx and lantiq share a lot of logic and introducing leds migration to another target would mean copying this code, again. Therefore add common logic to library in base-files package. Suggested-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
* base-files: make it possible to specify switch led modeChristian Lamparter2018-09-291-0/+2
| | | | | | | | | | | | | | | | | The swconfig switch led driver has the ability to switch between a "link, rx and/or tx" mode. However, this feature was not implemented in uci, the led init script and config_generate. This patch adds a seventh parameter to the ucidef_set_led_switch() function. The accepted values for this parameter are: link, rx and tx. Any permutations of these three values are supported, as long as they are properly encased with quotes. If the parameter is not specified it will default to "all" (link rx tx). Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: add network_get_metric() to /lib/functions/network.shFlorian Eckert2018-09-251-0/+5
| | | | | Signed-off-by: Florian Eckert <fe@dev.tdt.de> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
* base-files: add function to get mac as text from flashMathias Kresin2018-08-111-0/+23
| | | | | | | | | Add a function to get a mac stored as text from flash. The octets of the mac address need to be separated by any separator supported by macaddr_canonicalize(). Signed-off-by: Dmitry Tunin <hanipouspilot@gmail.com> Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: use consistent coding styleMathias Kresin2018-08-111-8/+4
| | | | | | | | Add the opening bracket right after the function name, to do it the same way for all functions in this file. Signed-off-by: Dmitry Tunin <hanipouspilot@gmail.com> Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: network.sh: gracefully handle missing network.interface ubus nsJo-Philipp Wich2018-07-171-4/+10
| | | | | | | | | | | | | | | | | | | | | When attempting to use any of the functions in network.sh while netifd is not started yet, the ubus interface dump query will fail with "Not found", yielding an empty response. Subsequently, jsonfilter is invoked with an empty string instead of a valid JSON document, causing it to emit a second "unexpected end of data" error. This caused the dnsmasq init script to log the following errors during early boot on some systems: procd: /etc/rc.d/S19dnsmasq: Command failed: Not found. procd: /etc/rc.d/S19dnsmasq: Failed to parse json data: unexpected end of data. Fix the issue by allowing the ubus query to fail with "Not found" but still logging other failures, and by passing an empty JSON object to jsonfilter if the interface status cache is empty. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: fix ucidef_set_interface() protocol selectionJo-Philipp Wich2018-05-251-5/+11
| | | | | | | | | | | | The previous refactoring of ucidef_set_interface() removed the protocol selection heuristic which breaks the networking defaults for the majority of boards. Re-add the protocol selection and rename two bad "proto" references to the expected "protocol" value. Fixes: 85048a9c1f ("base-files: rework _ucidef_set_interface to be more generic") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: rework _ucidef_set_interface to be more genericRoman Yeryomin2018-05-241-50/+24
| | | | | | | | | | | | This is a rework of previously submitted patch reworking ucidef_set_interface_raw [1]. Here, keep the idea but instead make _ucidef_set_interface more generic and use it instead of ucidef_set_interface_raw. Also change the users like ucidef_set_interface_lan and others. [1] https://patchwork.ozlabs.org/patch/844961/ Signed-off-by: Roman Yeryomin <roman@advem.lv>
* base-files: get_dt_led: don't warn about missing ledMathias Kresin2018-04-041-2/+1
| | | | | | | | | It's intentional that some boards within a target don't have all LEDs which are tried to be setup in a common script. Don't show a warning in such cases. Fixes: 4f4fc993db4c ("base-files: add more name source to get_dt_led helper function") Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: add more name source to get_dt_led helper functionMathias Kresin2018-03-141-1/+4
| | | | | | | | Not all LED driver are using the label devicetree property for the led name. Add support for the TI/National Semiconductor LP55xx Led Drivers, which are using the chan-name property for the led name, as fallback. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: add function to get binary mac from fileMathias Kresin2018-03-141-6/+13
| | | | | | | Add a fucntion to get the a binary mac address from file. Use the new function for mtd_get_mac_binary() to limit duplicate code. Signed-off-by: Mathias Kresin <dev@kresin.me>
* linux-atm: add br2684ctl option to specify the netdev nameMartin Schiller2018-01-101-0/+2
| | | | | | | | | | | Add the uci option nameprefix to specifc a target netdev name. Patch the br2684ctl code to accept and set a netdev name via commandline parameters. It allows to use the same netdev name for ATM and PTM lines on lantiq xdsl hardware. Signed-off-by: Martin Schiller <ms@dev.tdt.de> Signed-off-by: Mathis Kresin <dev@kresin.me>
* base-files: unify get_dt_led helper functionChristian Lamparter2017-12-141-0/+12
| | | | | | | | | | | | | | Lantiq and IPQ806X (which includes IPQ40XX) both define the same custom function {ipq806x|lantiq}_get_dt_led. This patch moves the function into the base-file package at lib/functions/leds.sh to make it more accessible for other targets as well. Cc: Mathias Kresin <dev@kresin.me> Cc: John Crispin <john@phrozen.org> Cc: Hannu Nyman <hannu.nyman@iki.fi> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: make ucidef_set_led_rssi offset and factor optionalMathias Kresin2017-06-171-2/+2
| | | | | | | | | | The offset and factor are only related for LEDs which can have different brightness values. But binary LEDs are more common and don't require any further configuation than setting the factor to 1. Use offset = 0 and factor = 1 in case nothing else is specified. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: network.sh: fix a number of IPv6 logic flawsJo-Philipp Wich2017-06-081-17/+48
| | | | | | | | | | | | | | | | | | | | | | * Change network_get_subnet6() to sensibly guess a suitable prefix Attempt to return the first non-linklocal, non-ula range, then attempt to return the first non-linklocal range and finally fall back to the previous behaviour of simply returning the first found item. * Fix network_get_ipaddrs_all() Instead of replicating the flawed logic appending a fixed ":1" suffix to IPv6 addresses, rely on network_get_ipaddrs() and network_get_ipaddrs6() to build a single list of all interface addresses. * Fix network_get_subnets6() Instead of replicating the flawed logic appending a fixed ":1" suffix to IPv6 addresses, rely on the ipv6-prefix-assignment.local-address field to figure out the proper network address. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: network.sh: properly report local IPv6 addressesJo-Philipp Wich2017-06-081-17/+13
| | | | | | | | | | Rework the network_get_ipaddr6() and network_get_ipaddrs6() functions to fetch the effective local IPv6 address of delegated prefix from the "local-address" field instead of naively hardcoding ":1" as static suffix. Fixes FS#829. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: add led functions to uci-defaults.shAlberto Bursi2017-05-141-0/+8
| | | | | | | | | | | | | uci_set_leds_ataport() allows to set a led to show activity on a specific (s)ata port, which is needed for devices that have a Sata led for each sata port. The led trigger is from the 834-ledtrig-libata.patch LEDE kernel patch. uci_set_leds_usbhost() allows to set a led to show total usb activity. Signed-off-by: Alberto Bursi <alberto.bursi@outlook.it> [Jo-Philipp Wich: use a single underscore to denote private functions] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: cleanup led functions in uci-defaults.shAlberto Bursi2017-05-141-145/+91
| | | | | | | | | | create a function with code common to all led functions, create another function with code common to functions setting a simple led trigger, restore alphabetical order in function names. Signed-off-by: Alberto Bursi <alberto.bursi@outlook.it> [Jo-Philipp Wich: use a single underscore to denote private functions] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: implement ucidef_set_hostname(), ucidef_set_ntpserver()Jo-Philipp Wich2017-05-031-0/+20
| | | | | | | | | | | | | | Commit 2036ae4 (base-files: support hostname and ntp servers through board.d) was supposed to implement these procedures but lacked the required changes to uci-defaults.sh. Add the missing procedures now to fix config generation on targets relying on hostname or NTP server presetting. Fixes FS#754. Reported-by: Cristian Morales Vega <cristian@samknows.com> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: always set proto passed to _ucidef_set_interface()Mathias Kresin2017-03-111-1/+1
| | | | | | | | | | | | | | | Overwrite an already set proto if a new one is passed to _ucidef_set_interface() similar to what is done for the interface. It is required when using ""ucidef_set_interface_wan 'ptm0' 'pppoe'" after some initial wan interface configuration is already done by ucidef_add_switch. The "json_is_a protocol string" guard is meant to not reset an earlier set interface proto in case something like "ucidef_set_interface_lan 'eth0'" is used afterwards. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: emit tagged switch configuration by defaultJo-Philipp Wich2017-02-021-1/+1
| | | | | | | | | | | | | | | | | | | Instead of only using tagged CPU port configurations when more than one VLAN is present on the switch, always emit tagged configurations unless a board explicitely opts out of this behaviour by using the previously introduced [0-9]u@netdev syntax. Emitting default tagged configurations has the following benefits: - Relation of switch vlans to netdevs is easier to understand, especially for multi-cpu-port switches - Adding additional VLANs (e.g. to break out a LAN port for other purposes) becomes easier as users are not forced to change the existing untagged VLAN to tagged and the existing ifname notation from ethX to ethX.Y anymore, drastly reducing the likelyhood of soft-bricks. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: uci-defaults: support requesting untagged switch port configurationJo-Philipp Wich2016-11-021-8/+14
| | | | | | | | | | | | | Introduce support for a new [0-9]u@netdev syntax to ucidev_add_switch() to let board.d network files request default network switch configurations which do not use tagged CPU ports. This commit itself has no effect on generated configurations at the moment since we still emit untagged configurations by default but it allows boards to opt-out from default tagged configs in case we start emitting tagged settings by default. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: add ucidef_set_led_usbport for full usbport supportRafał Miłecki2016-10-221-0/+24
| | | | | | | | | | | | | | | | | | | | This helper allows using usbport trigger directly. It requires usbport compatible syntax and supports specifying multiple USB ports, e.g.: ucidef_set_led_usbport "usb" "USB" "devicename:colour:function" "usb1-port1" "usb2-port1" This adds a proper object to the board.json, e.g. "usb": { "name": "USB", "type": "usbport", "sysfs": "devicename:colour:function", "ports": [ "usb1-port1", "usb2-port1" ] } and supports translating it into uci section. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: board_detect: allow specifying the generated fileJonas Gorski2016-08-131-2/+0
| | | | | | | Allow passing a filename to change the location of the generated board.json. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
* kernel: remove unused morse led trigger driverFelix Fietkau2016-08-041-11/+0
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* base-files: support port_state LED types in board.dJo-Philipp Wich2016-06-081-0/+19
| | | | | | Add support for handling port_state LEDs as used by ADM5120. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: add function ucidef_set_interface_raw to enable default ↵John Crispin2016-03-101-0/+6
| | | | | | | | configuration on interfaces other than lan and wan. Signed-off-by: Micke Prag <micke.prag@telldus.se> SVN-Revision: 48976
* lantiq: do not set default firmware fileFelix Fietkau2016-03-071-4/+2
| | | | | | | | | We are now shipping a DSL firmware, do not set it by default to some file name. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> SVN-Revision: 48941
* base-files: support passing mode to ucidef_set_led_netdev()Jo-Philipp Wich2016-02-261-0/+2
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 48806
* base-files: add support for speed mask to switch config init scriptsFelix Fietkau2016-02-251-0/+2
| | | | | | | | | | | This patch adds extra parameter to switch LED trigger initialization functions. New functionality maintains backward compatibility, so calling functions without setting new speed_mask parameter works as expected. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> SVN-Revision: 48776
* leds: support oneshot as well as timer triggersJohn Crispin2016-02-251-4/+13
| | | | | | | | | oneshot and timer have the same configuration options, just a different trigger name. Signed-off-by: Karl Palsson <karlp@etactica.com> SVN-Revision: 48770
* base-files: cleanup mtd_get_mac_binary hexdumpFelix Fietkau2015-12-191-1/+1
| | | | | | | | | Remove usage of dd, as per request from Yousong Zhou. <https://lists.openwrt.org/pipermail/openwrt-devel/2015-December/037743.html> Signed-off-by: Chris R Blake <chrisrblake93@gmail.com> SVN-Revision: 47949
* ar71xx: scan nand ubi partition for ath9k eeprom filesFelix Fietkau2015-12-191-0/+17
| | | | | | | | | | The MR18 stores the ath9k eeprom values on the NAND. This patch makes it possible to retrieve the images from there. Signed-off-by: Chris R Blake <chrisrblake93@gmail.com> SVN-Revision: 47948
* all: drop old uci-defaults.shJo-Philipp Wich2015-12-112-864/+519
| | | | | | | | | Replace former uci-defaults.sh implementation with the uci-defaults-new.sh one and update all users accordingly. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47867
* board.d: add support for gpio_switch sectionsJo-Philipp Wich2015-12-041-0/+15
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47762
* base-files: board.d: auto-set model id and name if /tmp/sysinfo is availableJo-Philipp Wich2015-12-041-0/+10
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47752
* base-files: board.d: support dsl modems, atm bridges and pppoe protocolJo-Philipp Wich2015-12-041-1/+47
| | | | | | | | | | | This adds support for specifying the dsl modem, atm bridge configs and setting the pppoe protocol for wan. These additions are required to port the Lantiq target to board.d. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47750
* all: remove dummy ucidef_set_interface_loopback() from board.dJo-Philipp Wich2015-12-031-6/+0
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47744
* base-files: board.d: support specifiying the protocol of lan and wanJo-Philipp Wich2015-12-031-10/+26
| | | | | | | | | Some boards, e.g. the Sheeva Plug, require the lan interface to be set to DHCP instead of a static address, therfore support that. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47732
* base-files: board.d: support timer ledsJo-Philipp Wich2015-12-031-0/+20
| | | | | | | | Add ucidef_set_led_timer() and handling for it to config_generate. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47731
* base-files: board.d: support ide ledsJo-Philipp Wich2015-12-031-0/+16
| | | | | | | | Add ucidef_set_led_ide() to define "ide-disk" triggered leds. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47729
* base-files: uci-defaults-new.sh: fix for handling multiple ifnamesJo-Philipp Wich2015-12-031-4/+4
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47728
* board.d: merge ucidef_add_switch() and ucidef_add_switch_ports()Jo-Philipp Wich2015-12-031-60/+50
| | | | | | | | | | | | This changes uci-defaults-new.sh, config_generate and all relevant board.d files in order combine ucidef_add_switch() and ucidef_add_switch_ports() into a single function. Also removes now superfluous enable and reset arguments. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47721
* base-files: uci-defaults-new: remove reset/enable args of ucidef_add_switch()Jo-Philipp Wich2015-12-031-14/+12
| | | | | | | | | | | | | | | Out of 69 switch definitions, only 3 pass something different than "1" as values for reset and enable, with one of those three being invalid. This change ... * removes the reset and enable arguments from ucidef_add_switch() * unconditionally writes reset:1 and enable:1 to JSON * converts the three users of nonstandard values to ucidef_add_switch_attr() Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47720
* base-files: uci-defaults-new, config_generate: refactor code and drop old vlansJo-Philipp Wich2015-12-031-50/+108
| | | | | | | | | | | | | | | Remove support for now unused ucidef_add_switch_vlan(), move port->vlan and vlan->interfaces conversion to uci-defaults-new.sh and massively simplify config_generate. This change prepares the following upcoming steps: * Eliminate use of ucidef_set_interface_lan_wan() for switch only devices * Merge ucidef_add_switch() with ucidef_add_switch_ports() Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47719
* base-files: uci-defaults-new, config_generate: allow force tagged cpu portsJo-Philipp Wich2015-11-301-2/+8
| | | | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47679
* base-files: uci-defaults-new: fix unquoted variablesJo-Philipp Wich2015-11-301-5/+5
| | | | | | | | | | Properly quote variables in ucidef_set_interface_lan() and ucidef_set_interface_lan(), otherwise interfaces with multiple devices are not properly written into the configuration. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47673
* base-files: uci-defaults-new: add board id and name helpersJo-Philipp Wich2015-11-301-0/+12
| | | | | | | | | Add ucidef_set_board_id() and ucidef_set_model_name() procedures to store model information in the board.json file. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47671