aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
Commit message (Collapse)AuthorAgeFilesLines
* failsafe: run on all consoles listed in /proc/cmdlineMark Mentovai2022-06-192-35/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On x86, when both CONFIG_GRUB_CONSOLE and CONFIG_GRUB_SERIAL are set (as they are by default), the kernel command line will have two console= entries, such as console=tty0 console=ttyS0,115200n8 Failsafe was only running a shell on the first defined console, the VGA console. This is a problem for devices like apu2, where there is only a serial console and it appears on ttyS0. Moreover, the console prompt to enter failsafe during boot was delivered to, and its input read from, the last console= on the kernel command line. So while the failsafe shell was on the first defined console, only the last defined console could be used to enter failsafe during boot. In contrast, the x86 bootloader (GRUB) operates on both the serial console and the VGA console by virtue of "terminal_{input,output} console serial". GRUB also provided an alternate means to enter failsafe from either console. The presence of two console= kernel command line parameters causes kernel messages to be delivered to both. Under normal operation (not failsafe), procd runs login in accordance with inittab, which on x86 specifies ttyS0, hvc0, and tty1, allowing login through any of serial, hypervisor, or VGA console. Thus, serial access was consistently available on x86 devices with serial consoles under normal operation, except for shell access in failsafe mode (without editing the kernel command line). By presenting the failsafe prompt, reading failsafe prompt input, and running failsafe shells on all consoles listed in /proc/cmdline, failsafe mode will work correctly on devices with a serial console (like apu2), and the same image without any need for reconfiguration can be shared by devices with the more traditional (for x86) VGA console. This improvement should benefit any system with multiple console= arguments, including x86 and bcm27xx (Raspberry Pi). Signed-off-by: Mark Mentovai <mark at moxienet.com>
* base-files: allow ignoring minor compat-version checkDavid Bauer2022-06-182-0/+5
| | | | | | | | | | | | Downstream projects might re-generate device-specific configuration based on OpenWrt's defaults on each upgrade, thus being unaffected by forward- as well as backwards-breaking configuration. Add a new sysupgrade parameter, which allows sysupgrades between minor compat-versions. Upgrades will still fail upon mismatching major compat versions. Signed-off-by: David Bauer <mail@david-bauer.net>
* base-files: simplify restorecon logicDaniel Golle2022-05-021-2/+2
| | | | | | | | | Remove forgotten redundant selinuxenabled call and skip the whole thing in case $IPKG_INSTROOT is set as labels are anyway applied only later on in fakeroot when squashfs is created. Fixes: 6d7272852e ("base-files: add missing $IPKG_INSTROOT to restorecon call") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: add missing $IPKG_INSTROOT to restorecon callDaniel Golle2022-05-021-1/+3
| | | | | | | Update to overlooked v2 version of Dominick Grift's patch. Fixes: 5109bd164c ("base-files: address sed in-place without SELinux awareness") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: address sed in-place without SELinux awarenessDominick Grift2022-05-021-0/+1
| | | | | | | | | | | | sed(1) in busybox does not support this functionality: https://git.savannah.gnu.org/cgit/sed.git/tree/sed/execute.c#n598 This causes /etc/group to become mislabeled when a package requests that a uid/gid be added on OpenWrt with SELinux Signed-off-by: Daniel Golle <daniel@makrotopia.org> [move restorecon inside lock] Signed-off-by: Dominick Grift <dominick.grift@defensec.nl>
* base-files: fix sysupgrade for kernel-out-of-UBIRodrigo Balerdi2022-05-021-2/+6
| | | | | | | | | | | | | | | | | | | | Commit ecbcc0b59551 bricks devices on which the raw kernel and UBI mtd partitions overlap. This is the case of the ZyXEL NR7101 for example. Its OEM bootloader has no UBI support. OpenWrt splits the stock kernel mtd partition into a raw kernel part used by the bootloader and a UBI part used to store rootfs and rootfs_data. Running mtd erase on the complete partition during sysupgrade erases the UBI part and results in a soft brick. Arguably the best solution would be to fix the partition layouts so that kernel and UBI partitions do not overlap, also including a stock_kernel partition to help reverting to stock firmware. This would have the added benefit of protecting UBI from kernel images that are excessively large. Fixes: ecbcc0b59551 ("base-files: safer sysupgrade.tar for kernel-out-of-UBI") Reported-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: minimize critical time in sysupgradeRodrigo Balerdi2022-04-191-5/+6
| | | | | | | | Attempt to minimize the time during which an interrupted nand sysupgrade can lead to a non-functional device by flushing caches before starting the upgrade procedure. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: trim unnecessary nand sysupgrade codeRodrigo Balerdi2022-04-191-4/+1
| | | | | | Remove unnecessary sync commands during nand sysupgrade. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: fix issues in nand sysupgradeRodrigo Balerdi2022-04-191-10/+21
| | | | | | | | | Fix issues while retaining configuration during nand sysupgrade: - abort configuration saving if data partition is not found - generate diagnostics if saving fails (eg, because of lack of space) - do not output "sysupgrade successful" in case of errors Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: clean up nand sysupgrade codeRodrigo Balerdi2022-04-191-9/+9
| | | | | | Fix some inconsistent quoting in nand sysupgrade code. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: clean up ubinized sysupgrade codeRodrigo Balerdi2022-04-191-7/+3
| | | | | | | | Remove redundant check from nand ubinized sysupgrade code. This check has already been done in the only caller of the affected function: nand_do_upgrade. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: clean up nand tar sysupgrade codeRodrigo Balerdi2022-04-191-34/+34
| | | | | | | | | | | | | | | | | Prepares code for ubirename-based safe sysupgrade implementation. Fixes several issues: - the special CI_KERNPART value "none" is ignored if an MTD partition named "none" exists - misleading variable names (such as has_kernel to mean "tar has kernel and it should not be written to an MTD partition but a UBI volume") - inconsistent treatment of zero-length tar member files - inconsistent meaning of "0" and "" variable values - redundant operations (unneeded untaring, repeated untaring, unneeded partition lookups) - inconsistent variable quoting Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: safer sysupgrade.tar for kernel-out-of-UBIRodrigo Balerdi2022-04-191-1/+5
| | | | | | | | | Ensure that the kernel CRC is invalidated while rootfs is being updated. This allows the bootloader to detect an interrupted sysupgrade and fall back to an alternate booting method, such as TFTP, instead of just going ahead with normal boot and effectively bricking the device. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: safer sysupgrade for kernel-in-UBI devicesRodrigo Balerdi2022-04-191-7/+7
| | | | | | | | | | | | | | Ensure that the kernel CRC is invalidated while rootfs is being updated. This allows the bootloader to detect an interrupted sysupgrade and fall back to an alternate booting method, instead of just going ahead with normal boot and effectively bricking the device. Possible fallbacks include a recovery initramfs partition or UBI volume and TFTP. See here for an example U-Boot configuration with fallbacks: https://shorturl.at/befsA (https://github.com/Lanchon/openwrt-tr4400-v2/ blob/e7d707d6bd7839fbd0b8d0bd180fce451df77e47/install-recovery.sh#L52-L63) Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: fix nand sysupgrade commentsRodrigo Balerdi2022-04-191-3/+3
| | | | | | Erroneous comments possibly applied to an earlier code revision. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: improve sysupgrade ubiblock handlingRodrigo Balerdi2022-04-191-16/+18
| | | | | | Only remove ubiblock devices required for nand sysupgrade. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: emit diagnostics on sysupgrade abortRodrigo Balerdi2022-04-191-11/+16
| | | | | | | Emit diagnostics if nand sysupgrade is aborted because UBI partition cannot be attached. Also avoid redudndant checks. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: more robust sysupgrade on NANDDaniel Golle2022-04-131-4/+10
| | | | | | | | | Make sure sysupgrade on NAND also works in case of UBI volumes having index >9. While at it, also make sure UBI device is detected and abort in case it isn't. Use Shell built-in shorthand ':' instead of 'true'. Fixes #9708 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* ipq40xx: Support Chromium OS image-type creationBrian Norris2022-03-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | See firmware-utils.git commits [1], which implemented the cros-vbutil verified-boot payload-packing tool, and extended ptgen for the CrOS kernel partition type. With these, it's now possible to package kernel + rootfs to make disk images that can boot a Chrome OS-based system (e.g., Chromebooks, or even a few AP models). Regarding PARTUUID= changes: Chromium bootloaders work well with a partition number offset (i.e., relative to the kernel partition), so we'll be using a slightly different root UUID line. NB: I've made this support specific to ip40xx for now, because I only plan to support an IPQ4019-based AP that uses a Chromium-based bootloader, but this image format can be used for essentially any Chromebook, as well as the Google OnHub, a prior Chromium-based AP using an IPQ8064 chipset. [1] ptgen: add Chromium OS kernel partition support https://git.openwrt.org/?p=project/firmware-utils.git;a=commit;h=6c95945b5de973026dc6f52eb088d0943efa96bb cros-vbutil: add Chrome OS vboot kernel-signing utility https://git.openwrt.org/?p=project/firmware-utils.git;a=commit;h=8e7274e02fdc6f2cb61b415d6e5b2e1c7e977aa1 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* base-files: add wrapper for procd service list commandFlorian Eckert2022-03-191-0/+8
| | | | | | | | | | | | | | | | A service managed by procd does have a json object with usefull information. This information could by dumped with the following command. ubus call service list "{ 'verbose':true, 'name': '<service-name>)'". }" This line is long and complicated to enter. This commit adds a wrapper call to the procd service section tool to simplify the input and get the output faster. We could now enter the command /etc/initd/<service> info to get the info faster. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
* procd: move service command to procdFlorian Eckert2022-03-191-21/+0
| | | | | | | | The service command belongs to the procd and does not belong in the shinit. In the course of the move, the script was also checked with shellcheck and cleaned up. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
* base-files: Align rootfs_data upgrades to 64KiB on eMMCBrian Norris2022-03-161-1/+4
| | | | | | | | | | | Rootfs overlays get created at a ROOTDEV_OVERLAY_ALIGN (64KiB) alignment after the rootfs, but emmc_do_upgrade() is assuming it comes at the very next 512-byte sector. Suggested-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> (move spaces around, mention fstools' libtoolfs) Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: call "sync" after initial setupRafał Miłecki2022-03-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenWrt uses a lot of (b)ash scripts for initial setup. This isn't the best solution as they almost never consider syncing files / data. Still this is what we have and we need to try living with it. Without proper syncing OpenWrt can easily get into an inconsistent state on power cut. It's because: 1. Actual (flash) inode and data writes are not synchronized 2. Data writeback can take up to 30 seconds (dirty_expire_centisecs) 3. ubifs adds extra 5 seconds (dirty_writeback_centisecs) "delay" Some possible cases (examples) for new files: 1. Power cut during 5 seconds after write() can result in all data loss 2. Power cut happening between 5 and 35 seconds after write() can result in empty file (inode flushed after 5 seconds, data flush queued) Above affects e.g. uci-defaults. After executing some migration script it may get deleted (whited out) without generated data getting actually written. Power cut will result in missing data and deleted file. There are three ways of dealing with that: 1. Rewriting all user-space init to proper C with syncs 2. Trying bash hacks (like creating tmp files & moving them) 3. Adding sync and hoping for no power cut during critical section This change introduces the last solution that is the simplest. It reduces time during which things may go wrong from ~35 seconds to probably less than a second. Of course it applies only to IO operations performed before /etc/init.d/boot . It's probably the stage when the most new files get created. All later changes are usually done using smarter C apps (e.g. busybox or uci) that creates tmp files and uses rename() that is expected to be atomic. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: Hauke Mehrtens <hauke@hauke-m.de> Acked-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
* base-file: remove password aging feature form /etc/shadowRucke Teg2022-02-241-1/+1
| | | | | | | | | | | | | | In the default shadow file, as visible in the failsafe mode, the user root has value of `0` set in the 3rd field, the date of last password change. This setting means that the password needs to be changed the next time the user will log in the system. `dropbear` server is ignoring this setting but `openssh-server` tries to enforce it and fails in the failsafe mode because the rootfs is R/O. Disable the password aging feature for user root by setting the 3rd filed empty. Signed-off-by: Rucke Teg <rucketeg@protonmail.com>
* base-files: make sure tools are present in sysupgrade ramdiskDaniel Golle2022-02-221-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not all targets create /var/lock or touch /var/lock/fw_printenv.lock in their platform.sh. This is problematic as fw_printenv then fails in case /var/lock/fw_printenv.lock has not been created by previous calls to fw_printenv/fw_setenv before sysupgrade is run. Targets using fw_printenv/fw_setenv during sysupgrade: * ath79/* * ipq40xx/* * ipq806x/* * kirkwood/* * layerscape/* * mediatek/mt7622 * mvebu/* * ramips/* * realtek/* Targets currently using additional steps in /lib/upgrade/platform.sh to make sure /var/lock/fw_printenv.lock (or at least /var/lock) actually exists: * ath79/* (openmesh devices) * ipq40xx/* (linksys devices) * ipq806x/* (linksys devices) * kirkwood/* (linksys devices) * layerscape/* * mvebu/cortexa9 (linksys devices) Given that accessing the U-Boot environment during sysupgrade is not uncommon and the situation across targets is currently quite diverse, just make sure both tools as well fw_env.config are always copied to the ramdisk used for sysupgrade. Also make sure /var/lock always exists. This now allows to remove copying of fw_printenv/fw_setenv as well as fw_env.config, creation of /var/lock or even /var/lock/fw_printenv.lock from lib/upgrade/platform.sh or files included there. As the same applies also to 'fwtool' which is used by generic eMMC sysupgrade, also always copy that to ramdisk. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: add support for heartbeat led triggerAlexey Smirnov2022-02-191-0/+9
| | | | | | | | | | | This patch adds support for creation heartbeat led trigger with, for example, this command: ucidef_set_led_heartbeat "..." "..." "..." from /etc/board.d/01_leds. Signed-off-by: Alexey Smirnov <s.alexey@gmail.com>
* base-files: Make sure rootfs_data_max is consideredDaniel Golle2022-02-171-8/+5
| | | | | | | | | | | | | | | For sysupgrade on NAND/UBI devices there is the U-Boot environment variable rootfs_data_max which can be used to limit the size of the rootfs_data volume created on sysupgrade. This stopped working reliable with recent kernels, probably due to a race condition when reading the number of free erase blocks from sysfs just after removing a volume. Change the script to just try creating rootfs_data with the desired size and retry with maximum size in case that fails. Hence calculating the available size in the script can be dropped which works around the problem. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: replace fgrep with grep -FRosen Penev2022-02-061-1/+1
| | | | | | | fgrep is deprecated and replaced by grep -F. The latter is used throughout the tree whereas this is the only usage of the former. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* base-files: upgrade: fix efi partitions size calculationJavier Marcet2021-12-271-1/+1
| | | | | | | | | We were missing (not using) the last sector of each partition, compared with the output of gparted. Signed-off-by: Javier Marcet <javier@marcet.info> [moved the dot] Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: fix service_running checkFlorian Eckert2021-12-041-3/+3
| | | | | | | | | | | | | | | | | | The following command checks if a instance of a service is running. /etc/init.d/<service> running <instance> In the variable `$@`, which is passed to the function `service_running`, the first argument is always the `instance` which should be checked. Because all other variables where removed from `$@` with `shift`. Before this change the first argument of `$@` was set to the `$service` Variable. So the function does not work as expected. The `$service` variable was always the instance which should be checked. This is not what we want. Signed-off-by: Florian Eckert <fe@dev.tdt.de> Reviewed-by: Sungbo Eo <mans0n@gorani.run>
* base-files: add eMMC sysupgrade supportEnrico Mioso2021-12-022-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | | Adds generic support for sysupgrading on eMMC-based devices. Provide function emmc_do_upgrade and emmc_copy_config to be used in /lib/upgrade/platform.sh instead of redundantly implementing the same logic over and over again. Similar to generic sysupgrade on NAND, use environment variables CI_KERNPART, CI_ROOTPART and newly introduce CI_DATAPART to indicate GPT partition names to be used. On devices with more than one MMC block device, CI_ROOTDEV can be used to specify the MMC device for partition name lookups. Also allow to select block devices directly using EMMC_KERN_DEV, EMMC_ROOT_DEV and EMMC_DATA_DEV, as using GPT partition names is not always an option (e.g. when forced to use MBR). To easily handle writing kernel and rootfs make use of sysupgrade.tar format convention which is also already used for generic NAND support. Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com> Signed-off-by: Daniel Golle <daniel@makrotopia.org> CC: Li Zhang <li.zhang@gl-inet.com> CC: TruongSinh Tran-Nguyen <i@truongsinh.pro>
* base-files: dont always create kernel UBI volumeRobert Marko2021-11-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently nand_upgrade_tar() will pass the kernel length to nand_upgrade_prepare_ubi() in all cases except for when the kernel is to be installed in a separate partition as a binary with the MTD tool. While this is fine for almost all cases newer MikroTik NAND devices like hAP ac3 require the kernel to be installed as a UBIFS packed UBI volume in its own partition. So, since we have a custom recipe to use ubiformat to flash the kernel in its partition it makes no sense for sysupgrade to also install the kernel as a UBI volume in the "ubi" partition as it only wastes space and will never be used. So, simply check whether CI_KERNPART is set to "none" and if so unset the "has_kernel" variable which will in turn prevent the kernel length from being passed on and then the kernel UBI volume wont be created for no usefull purpose. The ath79 MikroTik NAND target has been setting CI_KERNPART to "none" for a while now altough that was not preventing the kernel to be installed as UBI volume as well. Signed-off-by: Robert Marko <robimarko@gmail.com>
* base-files: stage2: improve /proc/*/stat parserDaniel Golle2021-11-131-2/+5
| | | | | | | | | | | Simply reading /proc/*/stat as a space-separated string will not work as the process name may itself contain spaces. Hence we must match on the '(' and ')' characters around the process name and can then handle the remaining string as space-separated values. This fixes shell error messages which have been popping up the console due to spaces in process names being interpreted as field separators. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: drop get_partition_by_name shell functionDaniel Golle2021-11-011-9/+0
| | | | | | | find_mmc_part provides a better alternative and all users of get_partition_by_name have been removed. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: allow specifiying rootdev for find_mmc_partDaniel Golle2021-11-011-2/+8
| | | | | | | | Some devices got more than one mmc device. Allow specifying the root device as 2nd parameter of find_mmc_part so scripts can avoid matching irrelevant partitions on wrong mmc device. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: add minimal mmc supportDavide Fioravanti2021-11-013-0/+35
| | | | | | | | | | | | | | | | Added minimal mmc support for helper functions: - find_mmc_part: Look for a given partition name. Returns the coresponding partition path - caldata_extract_mmc: Look for a given partition name and then extracts the calibration data - mmc_get_mac_binary: Returns the mac address from a given partition name and offset Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com> Signed-off-by: Robert Marko <robimarko@gmail.com> [replace dd with caldata_dd, moved sysupgrade mmc to orbi] Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files, metadata: support additional group membershipDaniel Golle2021-10-281-3/+20
| | | | | | | | | | | | Some packages may require additional group membership for the system user added by that package. Allow defining additional groups as third member of the ':'-separated tuple, allowing to specify multiple ','-separated groups with optional GID. Example: USERID:=foouser=1000:foogroup=1000:addg1=1001,addg2=1002,addg3 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: chmod 1777 /var/lockDeomid Ryabkov2021-10-231-2/+3
| | | | | | | | | | | | | Per FHS 3.0, /var/lock is the location for lock files [1]. However its current permissions (755) are too restrictive for use by unprivileged processes. Debian and Ubuntu set them to 1777, and now so do we. [1] <https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#varlockLockFiles> Signed-off-by: Deomid Ryabkov <rojer@rojer.me> [fixed typo in commit message, had to remove "rojer" due to git hooks] Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: reduce number of `mkdir` callsPaul Spooren2021-09-231-17/+19
| | | | | | | | | | | | | The `mkdir` commands supports passing multiple arguments to batch create multiple folders, instead of calling the tool every single time. If the creation of one of the folders fails, all other folder are still created and therefore doesn't change the error handling. Also stop creating `/etc/` explicitly after subfolders of `/etc/` were already created. Signed-off-by: Paul Spooren <mail@aparcar.org>
* base-files: reduce `sed` callsPaul Spooren2021-09-231-4/+2
| | | | | | | | | The `sed`-script shouldn't be called multiple times, especially not with the same files. This commit merges all files together in a single `sed`-script call. Signed-off-by: Paul Spooren <mail@aparcar.org>
* base-files: fix option to make /var persistentStijn Tintel2021-08-231-1/+1
| | | | | | | | | | | | The option was initially named TARGET_ROOTFS_LN_VAR_TMP, and the check was correct. When renaming the option to something more suitable, the check was changed to check for n, but when an option is not set, it's not n but empty. This results in the check always evaluating to false. Fix the check by checking for y with ifneq. Fixes: 57807f50ded6 ("base-files: add option to make /var persistent") Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* base-files: add option to make /var persistentStijn Tintel2021-08-221-0/+5
| | | | | | | | | | | | | | | | In OpenWrt, /var is symlinked to /tmp by default. This is done to reduce the amount of writes to the flash chip, which often have not the greatest durability. As a result, things like DHCP or UPnP lease files, are not persistent across reboots. Since OpenWrt can run on devices with more durable storage, it makes sense to have an option for a persistent /var. Add an option to make /var persistent. When enabled, /var will no longer be symlinked to /tmp, but /var/run will be symlink to /tmp/run, as it should contains only files that should not be kept during reboot. The option is off by default, to maintain the current behaviour. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* base-files: rename 'sdcard' to 'legacy-sdcard'Daniel Golle2021-08-162-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While an image layout based on MBR and 'bootfs' partition may be easy to understand for users who are very used to the IBM PC and always have the option to access the SD card outside of the device (and hence don't really depend on other recovery methods or dual-boot), in my opinion it's a dead end for many desirable features on embedded systems, especially when managed remotely (and hence without an easy option to access the SD card using another device in case things go wrong, for example). Let me explain: * using a MSDOS/VFAT filesystem to store kernel(s) is problematic, as a single corruption of the bootfs can render the system into a state that it no longer boots at all. This makes dual-boot useless, or at least very tedious to setup with then 2 independent boot partitions to avoid the single point of failure on a "hot" block (the FAT index of the boot partition, written every time a file is changed in bootfs). And well: most targets even store the bootloader environment in a file in that very same FAT filesystem, hence it cannot be used to script a reliable dual-boot method (as loading the environment itself will already fail if the filesystem is corrupted). * loading the kernel uImage from bootfs and using rootfs inside an additional partition means the bootloader can only validate the kernel -- if rootfs is broken or corrupted, this can lead to a reboot loop, which is often a quite costly thing to happen in terms of hardware lifetime. * imitating MBR-boot behavior with a FAT-formatted bootfs partition (like IBM PC in the 80s and 90s) is just one of many choices on embedded targets. There are much better options with modern U-Boot (which is what we use and build from source for all targets booting off SD cards), see examples in mediatek/mt7622 and mediatek/mt7623. Hence rename the 'sdcard' feature to 'legacy-sdcard', and prefix functions with 'legacy_sdcard_' instead of 'sdcard_'. Tested-by: Stijn Tintel <stijn@linux-ipv6.be> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: add generic sdcard upgrade methodStijn Tintel2021-08-072-0/+100
| | | | | | | | Add a generic sdcard upgrade method instead of duplicating code in yet another target, and add a feature flag to only install this upgrade method in targets that set this flag. Copied from mvebu. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* base-files: upgrade: try umount lvm and loop devicesDaniel Golle2021-08-041-0/+4
| | | | | | | | Try umount on device mapper and loop devices still mounted, so the subsequent call to disactivate all physical volumes and delete all loop devices is more likely to succeed. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: sysupgrade stage2: fix losetup detectionDaniel Golle2021-08-031-1/+1
| | | | | | | | | | | | If the busybox applet losetup was selected, `command -v` selects that during sysupgrade. As this applet is in another path and doesn't cover the '-D' option which is used to make sure user-defined loop devices are no longer active during sysupgrade. Detect losetup at the path of the full utility to avoid error messages in case of the busybox applet being selected. Reported-by: fda77 <fda77@users.noreply.github.com> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: wifi: tidy up the reconf codeBob Cantor2021-06-281-1/+2
| | | | | | | | | | | | commit 5edbd390d321532d9a697d6895a1a7c71c40bd5d rearranged the "wifi up" code. This commit tidies up the "wifi reconf" code so as to keep it aligned with the "wifi up" code. branches affected: trunk, 21.02 Signed-off-by: Bob Cantor <coxede6557@w3boats.com>
* base-files: wifi: swap the order of some ubus callsBob Cantor2021-06-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "/sbin/wifi up" makes three ubus calls: 1. ubus call network reload 2. ubus call network.wireless down 3. ubus call network.wireless up The first and third ubus calls call drv_mac80211_setup, while the second ubus call triggers wireless_device_setup_cancel, so the call sequence becomes, 1. drv_mac80211_setup 2. wireless_device_setup_cancel 3. drv_mac80211_setup This commit swaps the order of the first two ubus calls, 1. ubus call network.wireless down 2. ubus call network reload 3. ubus call network.wireless up Consequently drv_mac80211_setup is only called once, and two related bugs (#FS3784 and #FS3902) are no longer triggered by /sbin/wifi. branches affected: trunk, 21.02 Signed-off-by: Bob Cantor <coxede6557@w3boats.com>
* base-files: fix /tmp/TZ when zoneinfo not installedPaul Spooren2021-06-241-7/+4
| | | | | | | | | | | | The zoneinfo packages are not installed per default so neither /tmp/localtime nor /tmp/TZ is generated. This patch mostly reverts the previous fix and instead incooperates a solution suggested by Jo. Fixes "base-files: fix zoneinfo support " 8af62ed Signed-off-by: Paul Spooren <mail@aparcar.org>
* base-files: fix zoneinfo supportRosen Penev2021-06-231-7/+9
| | | | | | | | | | | | | | | | The system init script currently sets /tmp/localinfo when zoneinfo is populated. However, zoneinfo has spaces in it whereas the actual files have _ instead of spaces. This made the if condition never return true. Example failure when removing the if condition: /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles This file does not exist. America/Los_Angeles does. Ran through shfmt -w -ci -bn -sr -s Signed-off-by: Rosen Penev <rosenp@gmail.com>