aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* base-files: exit if mtd write command fails during sysupgradeRafał Miłecki2018-06-181-0/+1
| | | | | | | | | | It avoids confusing situations like: > Could not get image magic > Image check failed. > Upgrade completed > Rebooting system... Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: sysupgrade: fix handing get_image unpack commandsMatthias Schiffer2018-06-111-6/+6
| | | | | | | | On bcm53xx and brcm47xx, commands are passed to default_do_upgrade that expect the image to be passed on stdin, rather than as an argument. Fixes: 30f61a34b4cf ("base-files: always use staged sysupgrade") Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: fix UCI config parsing and callback handlingTony Ambardar2018-06-061-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several long-standing issues present in the UCI shell API as documented in https://wiki.openwrt.org/doc/devel/config-scripting. They relate both to high-level, user-defined callback functions used to process UCI config files, and also to low-level functions used within scripts generally. The related problems have been encountered now and in the past, e.g. https://forum.openwrt.org/viewtopic.php?id=54295, and include: a) UCI parsing option() function and user-defined option_cb() callbacks being erroneously called during processing of "list" config file entries; b) normal usage of the low-level config_set() unexpectedy calling any defined option_cb() if present; and c) handling of the list_cb() not respecting the NO_CALLBACK variable. Root causes include a function stack "inversion", where the low-level config_set() function incorrectly calls the high-level option() function, intended only for processing the "option" keyword of UCI config files. This change addresses the inversion and other issues, making the option handling code more consistent and smaller, and simplifying developers' usage of UCI callbacks. Signed-off-by: Tony Ambardar <itugrok@yahoo.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
* 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: /lib/functions.sh: remove unused insert_modulesMatthias Schiffer2018-04-171-10/+0
| | | | | | insert_modules has been unused since r5279. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* 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>
* base-files: don't evaluate block-device ueventDaniel Golle2018-02-131-4/+8
| | | | | | | | | | | | | Current code and also before commit da52dd0c83 was vulnerable to shell injection using volume lables in the GPT partition table of block devices. Given that partition names can be freely defined in GPT tables we really shouldn't evaluate a string which is potentially crafted with evil intentions. Hence rather use `export -n` to absorb the uevent's variables into the environment. Fixes commit da52dd0c83 (base-files: quote values when evaluating uevent) Signed-off-by: Daniel Golle <daniel@makrotopia.org> [mschiffer@universe-factory.net: suggested export -n usage]
* base-files: quote values when evaluating ueventDaniel Golle2018-02-111-3/+2
| | | | | | | | When sourcing /sys/class/block/*/uevent values have to be quoted as they may contain spaces (e.g. in PARTNAME). Fix this by pre-processing with sed before sourcing. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* 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>
* procd: nand: remove nand_board_name platform overrideMathias Kresin2017-12-081-9/+0
| | | | | | It isn't uses anymore by any target. Signed-off-by: Mathias Kresin <dev@kresin.me>
* procd: nand: dont rely on boardname in nand_upgrade_tarMathias Kresin2017-12-081-7/+9
| | | | | | | | | | | | | | | | Kernel and rootfs in a subdirectory matching the userspace boardname, was intended to use a single sysupgrade-tar archive for multiple boards with different kernel/rootfs images. This feature was never used. Use the first found directory in the tar archive instead of relying on a directory named according to the userspace boardname. It allows to change the boardname without adding another compatibility layer - using the nand_board_name() function - for (sub)targets using the metadata based image validation in favour to nand_do_platform_check(). Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: upgrade: make get_partitions() endian agnosticChristian Lamparter2017-12-081-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes two issues with the current get_partitions() function. First: "Invalid partition table on $disk" will pop up on legitimate images on big endian system. This is because the little-endian representation of "55 AA" is assumed in the context of little-endian architectures. On these comparing it to the 16-bit word 0xAA55 does work as intented. Whereas on big-endian systems, this would have to be 0x55AA. This patch fixes the issue by replacing the integer conversion and value match check with just a string comparision. Second: The extraction of the type, start LBA and LBA num from the partition table has the same endianness issue. This has been fixed by using the new hex_le32_to_cpu() function. This function will translate the stored little-endian data to the correct byte-order if necessary. Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* merge: base: update base-files and basic configZoltan HERPAI2017-12-081-1/+1
| | | | Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
* sysupgrade: don't kill our own parentMat Trudel2017-11-151-2/+3
| | | | | | | | Add the parent of the sysupgrade script to the list of pids not getting killed Signed-off-by: Mat Trudel <mat@geeky.net> Signed-off-by: John Crispin <john@phrozen.org>
* base-files: fix getting gid from group_add_nextYousong Zhou2017-11-091-7/+6
| | | | | | | | | | | | Shell function return code only has range [0, 255]. Other values will be truncated, e.g. return 65536 will have the same effect as return 0 While at it, drop other "return $rc" where rc will almost always take value 0 and whose value current callers actually do not check Fixes FS#988 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* functions.sh: fix default_postinst functionMarko Ratkaj2017-11-081-1/+1
| | | | | | | | | | | | | | | | | | When we run "opkg install" on a package that installs an uci-defaults script, functions.sh will fail to evaluate that script in its default_postinst function. This happens because there is no "./" present and it searches for the file in paths specified by the PATH variable. This would work on bash, but it will not work on ash and some other shells like sh, zsh. This applys to the ". filename" directive used in this case. This patch will make the path relative to the /etc/uci-defaults directory. Fixes: FS#1021 Signed-off-by: Marko Ratkaj <marko.ratkaj@sartura.hr>
* include: kernel.mk: simplify module autoloadingJo-Philipp Wich2017-11-071-0/+4
| | | | | | | | | | | | | | | | | | Let the generic postinstall script invoke "kmodloader" when the just installed package contains any /etc/module.d/ entries. This allows us to skip the explicit "insert_module()" calls in the package postinstall. Due to the removed insert_module calls we do not need to assemble a complete list of modules per package anymore, which allows for vast simplification of the package generation code. While we're at it, also support specifying default parameters for modules using either the MODPARAM or MODPARAM.modulename variables in KernelPackage. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* base-files: drop unused preinit_echo functionRafał Miłecki2017-08-091-5/+0
| | | | | | It isn't used for years since the old 99_10_run_init has been dropped. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: don't setup network in preinit if failsafe is disabledRafał Miłecki2017-08-091-1/+4
| | | | | | | | | | | | With failsafe disabled there is no point in early network setup. We don't send announcement over UDP and there is no way to ssh to the device. A side effect of this is avoiding a possibly incorrect network config (only with failsafe disabled). This problem is related to possible changes made by user in /etc/config/network. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: upgrade: don't loop forever trying to kill processesMatthias Schiffer2017-07-201-1/+10
| | | | | | | | | | When processes don't die on SIGKILL (usually because of kernel bugs), it's better to give up instead of looping forever. upgraded will trigger a reboot in this case (and if this fails, a hardware watchdog will eventually time out and reset the system, if present). Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* treewide: populate boardname and model earlierMathias Kresin2017-07-151-0/+0
| | | | | | | | | | | | | For targets using the generic board detection and board specific settings in diag.sh, the board name is still unset at the time the set_state() provided by diag.sh is called by 10_indicate_preinit. Change the execution order to ensure the boardname is populated before required the first time. Do the target specific board detection as early as possible, directly followed by the generic one to allow a seamless switch to the generic function for populating /tmp/sysinfo/. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: automatically handle paths and symlinks for RAMFS_COPY_BINMatthias Schiffer2017-07-112-37/+33
| | | | | | | | | | | | Depending on busybox applet selection, paths of basic utiilties may differ, and may not work as symlinks to busybox. Simply using whatever binary is found in PATH and detecting symlinks automatically is more robust and easier to maintain. The list of binaries is also slightly cleaned up and duplicates are removed. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* bcm53xx: upgrade: fix RAMFS_COPY_*Matthias Schiffer2017-07-111-1/+1
| | | | | Fixes: 30f61a34b4cf "base-files: always use staged sysupgrade" Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: upgrade: correctly handle nand_do_upgrade argument passed from ↵Matthias Schiffer2017-07-112-2/+2
| | | | | | | preupgrade Fixes: 30f61a34b4cf "base-files: always use staged sysupgrade" Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: allocate uid/gid starting from 65536Yousong Zhou2017-06-181-4/+4
| | | | | | | | | | | There already exist static assignment of uid/gid 65533 in packages feed and we have nobody/nogroup taking 65534 as their ids. Let's change the pid of dynamic assignment to start from 65536 so that the two assignment scheme will not collide with each other While at it, fix the scan command checking existence of uid/gid Signed-off-by: Yousong Zhou <yszhou4tech@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: board.json's switch reset means existence, not argumentJonas Gorski2017-06-111-1/+4
| | | | | | | Don't pass the value unconditionally to swconfig as a parameter but instead only call reset if it is 1. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
* 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>
* mvebu: fix sysupgradeMatthias Schiffer2017-06-011-1/+1
| | | | | | | | | | | | | | | | | mvebu was modifying RAMFS_COPY_BIN and RAMFS_COPY_DATA from a sysupgrade_pre_upgrade hook. As the ramfs is created from stage2, this did not have an effect anymore after the staged sysupgrade changes. As it doesn't really hurt to copy fw_printenv and fw_setenv unconditionally, simply add them in /lib/upgrade/platform.sh, so stage2 will see them. Config copying is moved to a function called by platform_copy_config, where it belongs. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Fixes: FS#821 Fixes: 30f61a34b4cf "base-files: always use staged sysupgrade"
* base-files: nand: use CI_KERNPART whenever the kernel volume is neededChristian Lamparter2017-05-311-4/+4
| | | | | | | | | | | | | | | | | | The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. This patch is in continuation of: commit 93aa86040523 "procd: nand: make it possible to configure kernel and ubi partition" The $CI_KERNPART variable should be used in place of the fixed "kernel" partition name. This allows targets to specifiy alternate names for the kernel partition. Cc: Chris Blake <chrisrblake93@gmail.com> Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
* base-files: add support for staged sysupgrades from failsafe modeMatthias Schiffer2017-05-292-5/+12
| | | | Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: sysupgrade cleanupMatthias Schiffer2017-05-292-103/+102
| | | | | | | | | | | | Some functions only used by stage2 are moved there from common.sh. One piece that could still use more cleanup is platform_pre_upgrade: many targets reference files from there are aren't available in the ramfs, so we need to evaluate it before the switch; conversely, flash writes happen in that function on some targets. Targets that do the latter should be fixed eventually to use platform_do_upgrade for that purpose. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: always use staged sysupgradeMatthias Schiffer2017-05-293-117/+116
| | | | | | | | | | | Support for the -d and -p options is dropped; it may be added again at some point by adding these flags to the ubus sysupgrade call. A downside of this is that we get a lot less information about the progress of the upgrade: as soon as the actual upgrade starts, all shell sessions are killed to allow unmounting the root filesystem. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* procd: remove procd-nand packageMatthias Schiffer2017-05-291-0/+376
| | | | | | | | | | | We always want to support staged upgrades now, so it's better to include upgraded into the main package. /lib/upgrade/nand.sh is moved to base-files. The procd-nand-firstboot package is removed for now, it may return later as a separate package. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* 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: add generic board_name function to functions.shFelix Fietkau2017-03-221-0/+4
| | | | | | | This will be used to replace all those nasty board specific scripts that do basically the same thing Signed-off-by: Felix Fietkau <nbd@nbd.name>
* 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: don't overwrite model name set by targetMathias Kresin2017-01-301-1/+1
| | | | | | | | | | | The condition is always true due to the literal string followed the -n test parameter. A model name set by target scripts always gets overwritten this way. Change the condition to check for an already existing destination file as it was before 5e85ae9 ("base-files: fix error message during boot"). Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: save /bin/mknod for sysupgradeFelix Fietkau2017-01-061-1/+2
| | | | | | It is used on NAND devices in case hotplug is too slow Signed-off-by: Felix Fietkau <nbd@nbd.name>
* base-files: export x86 platform upgrade functions to common.shYousong Zhou2017-01-051-0/+90
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* base-files: add support for overlaying rootfs contentRafał Miłecki2016-12-201-0/+5
| | | | | | | | | This adds support for install-overlay define. When used in package it allows installing files to a special directory that gets copied to the root when installing it. It allows overwriting files provided by other packages. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: add a hint in sysupgrade that shows what to do when the image ↵Felix Fietkau2016-12-041-0/+3
| | | | | | metadata check fails Signed-off-by: Felix Fietkau <nbd@nbd.name>