From 8d5b5ba3202a468d60ea59aca58a306d6733e474 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 00:24:02 +0800 Subject: [PATCH] update 2023-09-26 00:24:02 --- base-files/Makefile | 249 ++ base-files/files/bin/board_detect | 14 + base-files/files/bin/config_generate | 542 +++ base-files/files/bin/ipcalc.sh | 88 + base-files/files/etc/banner | 8 + base-files/files/etc/banner.failsafe | 15 + .../files/etc/board.d/99-default_network | 16 + base-files/files/etc/device_info | 4 + base-files/files/etc/diag.sh | 52 + base-files/files/etc/ethers | 6 + base-files/files/etc/fstab | 1 + base-files/files/etc/group | 11 + base-files/files/etc/hosts | 5 + base-files/files/etc/hotplug.d/net/00-sysctl | 9 + base-files/files/etc/init.d/boot | 55 + base-files/files/etc/init.d/done | 17 + base-files/files/etc/init.d/gpio_switch | 66 + base-files/files/etc/init.d/led | 145 + base-files/files/etc/init.d/sysctl | 44 + base-files/files/etc/init.d/sysfixtime | 44 + base-files/files/etc/init.d/system | 45 + base-files/files/etc/init.d/umount | 13 + base-files/files/etc/inittab | 3 + base-files/files/etc/iproute2/ematch_map | 8 + base-files/files/etc/iproute2/rt_protos | 18 + base-files/files/etc/iproute2/rt_tables | 12 + base-files/files/etc/openwrt_release | 7 + base-files/files/etc/openwrt_version | 1 + base-files/files/etc/os-release | 1 + base-files/files/etc/passwd | 5 + base-files/files/etc/preinit | 29 + base-files/files/etc/profile | 40 + base-files/files/etc/protocols | 57 + base-files/files/etc/rc.button/failsafe | 5 + base-files/files/etc/rc.button/power | 7 + base-files/files/etc/rc.button/reboot | 12 + base-files/files/etc/rc.button/reset | 31 + base-files/files/etc/rc.button/rfkill | 32 + base-files/files/etc/rc.common | 194 ++ base-files/files/etc/rc.local | 4 + base-files/files/etc/services | 173 + base-files/files/etc/shadow | 5 + base-files/files/etc/shells | 1 + base-files/files/etc/shinit | 12 + base-files/files/etc/sysctl.conf | 1 + base-files/files/etc/sysctl.d/10-default.conf | 28 + base-files/files/etc/sysupgrade.conf | 5 + .../files/etc/uci-defaults/10_migrate-shadow | 10 + .../etc/uci-defaults/12_network-generate-ula | 13 + .../files/etc/uci-defaults/13_fix-group-user | 9 + base-files/files/lib/functions.sh | 436 +++ base-files/files/lib/functions/caldata.sh | 184 + base-files/files/lib/functions/leds.sh | 94 + base-files/files/lib/functions/migrations.sh | 67 + base-files/files/lib/functions/network.sh | 325 ++ base-files/files/lib/functions/preinit.sh | 87 + base-files/files/lib/functions/service.sh | 103 + base-files/files/lib/functions/system.sh | 302 ++ .../files/lib/functions/uci-defaults.sh | 681 ++++ .../files/lib/preinit/02_default_set_state | 5 + base-files/files/lib/preinit/02_sysinfo | 10 + .../files/lib/preinit/10_indicate_failsafe | 17 + .../files/lib/preinit/10_indicate_preinit | 207 ++ base-files/files/lib/preinit/30_failsafe_wait | 102 + .../files/lib/preinit/40_run_failsafe_hook | 16 + .../lib/preinit/50_indicate_regular_preinit | 9 + .../files/lib/preinit/70_initramfs_test | 12 + base-files/files/lib/preinit/80_mount_root | 35 + .../files/lib/preinit/99_10_failsafe_login | 15 + base-files/files/lib/preinit/99_10_run_init | 8 + base-files/files/lib/upgrade/common.sh | 317 ++ base-files/files/lib/upgrade/do_stage2 | 25 + base-files/files/lib/upgrade/emmc.sh | 67 + base-files/files/lib/upgrade/fwtool.sh | 93 + .../lib/upgrade/keep.d/base-files-essential | 11 + base-files/files/lib/upgrade/legacy-sdcard.sh | 91 + base-files/files/lib/upgrade/nand.sh | 482 +++ base-files/files/lib/upgrade/stage2 | 175 + base-files/files/rom/note | 3 + base-files/files/sbin/firstboot | 3 + base-files/files/sbin/hotplug-call | 18 + base-files/files/sbin/led.sh | 25 + base-files/files/sbin/pkg_check | 130 + base-files/files/sbin/sysupgrade | 384 +++ base-files/files/sbin/wifi | 271 ++ base-files/files/usr/lib/os-release | 18 + base-files/files/usr/libexec/login.sh | 5 + .../files/usr/libexec/validate_firmware_image | 66 + base-files/image-config.in | 284 ++ dnsmasq/Makefile | 204 ++ dnsmasq/files/50-dnsmasq-migrate-ipset.sh | 32 + .../50-dnsmasq-migrate-resolv-conf-auto.sh | 8 + dnsmasq/files/dhcp-script.sh | 53 + dnsmasq/files/dhcp.conf | 37 + dnsmasq/files/dhcpbogushostname.conf | 8 + dnsmasq/files/dnsmasq.conf | 37 + dnsmasq/files/dnsmasq.init | 1333 +++++++ dnsmasq/files/dnsmasq_acl.json | 15 + dnsmasq/files/dnsmasqsec.hotplug | 12 + dnsmasq/files/rfc6761.conf | 11 + ...00-remove-old-runtime-kernel-support.patch | 165 + dnsmasq/patches/200-ubus_dns.patch | 282 ++ firewall/Makefile | 64 + firewall/files/firewall.config | 206 ++ firewall/files/firewall.hotplug | 11 + firewall/files/firewall.init | 61 + firewall/files/firewall.user | 7 + firewall4/Makefile | 50 + fullconenat/Makefile | 71 + fullconenat/patches/000-printk.patch | 16 + fullconenat/src/Makefile | 12 + libnftnl/Makefile | 76 + ...ftnl-add-fullcone-expression-support.patch | 253 ++ miniupnpd-iptables/Makefile | 80 + miniupnpd-iptables/files/firewall.include | 57 + miniupnpd-iptables/files/miniupnpd.defaults | 13 + miniupnpd-iptables/files/miniupnpd.hotplug | 39 + miniupnpd-iptables/files/miniupnpd.init | 219 ++ miniupnpd-iptables/files/upnpd.config | 27 + .../patches/100-no-daemon.patch | 25 + .../patches/101-no-ssl-uuid.patch | 23 + .../patches/102-ipv6-ext-port.patch | 10 + .../patches/103-no-ipv6-autodetection.patch | 27 + .../patches/104-always-libuuid.patch | 20 + .../patches/105-build-with-kernel-5.4.patch | 90 + .../patches/106-spam-syslog-ignoring.patch | 13 + nftables/Makefile | 85 + ...bles-add-fullcone-expression-support.patch | 209 ++ opkg/Makefile | 98 + opkg/files/20_migrate-feeds | 9 + opkg/files/customfeeds.conf | 3 + opkg/files/opkg-key | 58 + opkg/files/opkg-smime.conf | 6 + opkg/files/opkg.conf | 4 + ppp/Makefile | 311 ++ ppp/files/etc/ppp/chap-secrets | 1 + ppp/files/etc/ppp/filter | 23 + ppp/files/etc/ppp/options | 8 + ppp/files/etc/ppp/options.pptp | 7 + ppp/files/etc/ppp/radius.conf | 8 + ppp/files/etc/ppp/radius/dictionary | 253 ++ ppp/files/etc/ppp/radius/dictionary.asnet | 3 + ppp/files/etc/ppp/radius/dictionary.microsoft | 80 + ppp/files/etc/ppp/radius/servers | 2 + ppp/files/lib/netifd/ppp-down | 13 + ppp/files/lib/netifd/ppp-up | 20 + ppp/files/lib/netifd/ppp6-up | 32 + ppp/files/ppp.sh | 328 ++ .../010-use_target_for_configure.patch | 24 + ppp/patches/105-debian_demand.patch | 170 + .../120-debian_ipv6_updown_option.patch | 95 + ppp/patches/133-fix_sha1_include.patch | 11 + ppp/patches/200-makefile.patch | 56 + ppp/patches/201-mppe_mppc_1.1.patch | 1518 ++++++++ ppp/patches/203-opt_flags.patch | 38 + ppp/patches/204-radius_config.patch | 72 + ppp/patches/205-no_exponential_timeout.patch | 29 + ppp/patches/207-lcp_mtu_max.patch | 25 + ppp/patches/208-fix_status_code.patch | 24 + .../300-filter-pcap-includes-lib.patch | 20 + ppp/patches/310-precompile_filter.patch | 194 ++ ...multilink_support_custom_iface_names.patch | 147 + .../330-retain_foreign_default_routes.patch | 22 + .../340-populate_default_gateway.patch | 34 + ppp/patches/400-simplify_kernel_checks.patch | 154 + ppp/patches/401-no_record_file.patch | 39 + ppp/patches/403-no_wtmp.patch | 25 + .../404-remove_obsolete_protocol_names.patch | 151 + ppp/patches/405-no_multilink_option.patch | 28 + ppp/patches/500-add-pptp-plugin.patch | 3066 +++++++++++++++++ ppp/patches/510-pptp_compile_fix.patch | 11 + ppp/patches/511-pptp_cflags.patch | 11 + ...openssl-for-the-DES-instead-of-the-l.patch | 89 + ppp/patches/610-pppd_compile_fix.patch | 12 + ppp/utils/pfc.c | 51 + ucl/Makefile | 69 + ucl/patches/001-autoconf-compat.patch | 11 + upx/Makefile | 61 + vsftpd-alt/Makefile | 98 + vsftpd-alt/files/vsftpd-uci.init | 14 + vsftpd-alt/files/vsftpd.conf | 30 + vsftpd-alt/files/vsftpd.init | 13 + vsftpd-alt/files/vsftpd.uci | 50 + vsftpd-alt/files/vsftpd_prepare | 258 ++ vsftpd-alt/files/vsftpd_wrapper | 49 + vsftpd-alt/patches/001-destdir.patch | 47 + vsftpd-alt/patches/002-find_libs.patch | 13 + vsftpd-alt/patches/003-chroot.patch | 11 + .../patches/004-disable-capabilities.patch | 12 + vsftpd-alt/patches/005-disable-pam.patch | 11 + .../patches/006-musl-compatibility.patch | 13 + vsftpd-alt/patches/007-CVE-2015-1419.patch | 91 + .../patches/010-openssl-deprecated.patch | 51 + .../patches/100-add-uci-auth-support.patch | 127 + .../101-enable-chroot-on-writable-dir.patch | 19 + .../patches/102-keep-local-user-rights.patch | 11 + wireless-regdb/Makefile | 32 + .../patches/500-world-regd-5GHz.patch | 16 + .../600-custom-change-txpower-and-dfs.patch | 30 + 199 files changed, 19836 insertions(+) create mode 100644 base-files/Makefile create mode 100755 base-files/files/bin/board_detect create mode 100755 base-files/files/bin/config_generate create mode 100755 base-files/files/bin/ipcalc.sh create mode 100644 base-files/files/etc/banner create mode 100644 base-files/files/etc/banner.failsafe create mode 100644 base-files/files/etc/board.d/99-default_network create mode 100644 base-files/files/etc/device_info create mode 100644 base-files/files/etc/diag.sh create mode 100644 base-files/files/etc/ethers create mode 100644 base-files/files/etc/fstab create mode 100644 base-files/files/etc/group create mode 100644 base-files/files/etc/hosts create mode 100644 base-files/files/etc/hotplug.d/net/00-sysctl create mode 100755 base-files/files/etc/init.d/boot create mode 100755 base-files/files/etc/init.d/done create mode 100755 base-files/files/etc/init.d/gpio_switch create mode 100755 base-files/files/etc/init.d/led create mode 100755 base-files/files/etc/init.d/sysctl create mode 100755 base-files/files/etc/init.d/sysfixtime create mode 100755 base-files/files/etc/init.d/system create mode 100755 base-files/files/etc/init.d/umount create mode 100644 base-files/files/etc/inittab create mode 100644 base-files/files/etc/iproute2/ematch_map create mode 100644 base-files/files/etc/iproute2/rt_protos create mode 100644 base-files/files/etc/iproute2/rt_tables create mode 100644 base-files/files/etc/openwrt_release create mode 100644 base-files/files/etc/openwrt_version create mode 120000 base-files/files/etc/os-release create mode 100644 base-files/files/etc/passwd create mode 100755 base-files/files/etc/preinit create mode 100644 base-files/files/etc/profile create mode 100644 base-files/files/etc/protocols create mode 100755 base-files/files/etc/rc.button/failsafe create mode 100755 base-files/files/etc/rc.button/power create mode 100755 base-files/files/etc/rc.button/reboot create mode 100755 base-files/files/etc/rc.button/reset create mode 100755 base-files/files/etc/rc.button/rfkill create mode 100755 base-files/files/etc/rc.common create mode 100644 base-files/files/etc/rc.local create mode 100644 base-files/files/etc/services create mode 100644 base-files/files/etc/shadow create mode 100644 base-files/files/etc/shells create mode 100644 base-files/files/etc/shinit create mode 100644 base-files/files/etc/sysctl.conf create mode 100644 base-files/files/etc/sysctl.d/10-default.conf create mode 100644 base-files/files/etc/sysupgrade.conf create mode 100644 base-files/files/etc/uci-defaults/10_migrate-shadow create mode 100644 base-files/files/etc/uci-defaults/12_network-generate-ula create mode 100644 base-files/files/etc/uci-defaults/13_fix-group-user create mode 100644 base-files/files/lib/functions.sh create mode 100644 base-files/files/lib/functions/caldata.sh create mode 100644 base-files/files/lib/functions/leds.sh create mode 100644 base-files/files/lib/functions/migrations.sh create mode 100644 base-files/files/lib/functions/network.sh create mode 100644 base-files/files/lib/functions/preinit.sh create mode 100644 base-files/files/lib/functions/service.sh create mode 100644 base-files/files/lib/functions/system.sh create mode 100644 base-files/files/lib/functions/uci-defaults.sh create mode 100644 base-files/files/lib/preinit/02_default_set_state create mode 100644 base-files/files/lib/preinit/02_sysinfo create mode 100644 base-files/files/lib/preinit/10_indicate_failsafe create mode 100644 base-files/files/lib/preinit/10_indicate_preinit create mode 100644 base-files/files/lib/preinit/30_failsafe_wait create mode 100644 base-files/files/lib/preinit/40_run_failsafe_hook create mode 100644 base-files/files/lib/preinit/50_indicate_regular_preinit create mode 100644 base-files/files/lib/preinit/70_initramfs_test create mode 100644 base-files/files/lib/preinit/80_mount_root create mode 100644 base-files/files/lib/preinit/99_10_failsafe_login create mode 100644 base-files/files/lib/preinit/99_10_run_init create mode 100644 base-files/files/lib/upgrade/common.sh create mode 100755 base-files/files/lib/upgrade/do_stage2 create mode 100644 base-files/files/lib/upgrade/emmc.sh create mode 100644 base-files/files/lib/upgrade/fwtool.sh create mode 100644 base-files/files/lib/upgrade/keep.d/base-files-essential create mode 100644 base-files/files/lib/upgrade/legacy-sdcard.sh create mode 100644 base-files/files/lib/upgrade/nand.sh create mode 100755 base-files/files/lib/upgrade/stage2 create mode 100644 base-files/files/rom/note create mode 100755 base-files/files/sbin/firstboot create mode 100755 base-files/files/sbin/hotplug-call create mode 100755 base-files/files/sbin/led.sh create mode 100755 base-files/files/sbin/pkg_check create mode 100755 base-files/files/sbin/sysupgrade create mode 100755 base-files/files/sbin/wifi create mode 100644 base-files/files/usr/lib/os-release create mode 100755 base-files/files/usr/libexec/login.sh create mode 100755 base-files/files/usr/libexec/validate_firmware_image create mode 100644 base-files/image-config.in create mode 100644 dnsmasq/Makefile create mode 100755 dnsmasq/files/50-dnsmasq-migrate-ipset.sh create mode 100755 dnsmasq/files/50-dnsmasq-migrate-resolv-conf-auto.sh create mode 100755 dnsmasq/files/dhcp-script.sh create mode 100644 dnsmasq/files/dhcp.conf create mode 100644 dnsmasq/files/dhcpbogushostname.conf create mode 100644 dnsmasq/files/dnsmasq.conf create mode 100755 dnsmasq/files/dnsmasq.init create mode 100644 dnsmasq/files/dnsmasq_acl.json create mode 100644 dnsmasq/files/dnsmasqsec.hotplug create mode 100644 dnsmasq/files/rfc6761.conf create mode 100644 dnsmasq/patches/100-remove-old-runtime-kernel-support.patch create mode 100644 dnsmasq/patches/200-ubus_dns.patch create mode 100644 firewall/Makefile create mode 100644 firewall/files/firewall.config create mode 100644 firewall/files/firewall.hotplug create mode 100755 firewall/files/firewall.init create mode 100644 firewall/files/firewall.user create mode 100644 firewall4/Makefile create mode 100644 fullconenat/Makefile create mode 100644 fullconenat/patches/000-printk.patch create mode 100644 fullconenat/src/Makefile create mode 100644 libnftnl/Makefile create mode 100644 libnftnl/patches/001-libnftnl-add-fullcone-expression-support.patch create mode 100644 miniupnpd-iptables/Makefile create mode 100644 miniupnpd-iptables/files/firewall.include create mode 100644 miniupnpd-iptables/files/miniupnpd.defaults create mode 100644 miniupnpd-iptables/files/miniupnpd.hotplug create mode 100644 miniupnpd-iptables/files/miniupnpd.init create mode 100644 miniupnpd-iptables/files/upnpd.config create mode 100644 miniupnpd-iptables/patches/100-no-daemon.patch create mode 100644 miniupnpd-iptables/patches/101-no-ssl-uuid.patch create mode 100644 miniupnpd-iptables/patches/102-ipv6-ext-port.patch create mode 100644 miniupnpd-iptables/patches/103-no-ipv6-autodetection.patch create mode 100644 miniupnpd-iptables/patches/104-always-libuuid.patch create mode 100644 miniupnpd-iptables/patches/105-build-with-kernel-5.4.patch create mode 100644 miniupnpd-iptables/patches/106-spam-syslog-ignoring.patch create mode 100644 nftables/Makefile create mode 100644 nftables/patches/002-nftables-add-fullcone-expression-support.patch create mode 100644 opkg/Makefile create mode 100644 opkg/files/20_migrate-feeds create mode 100644 opkg/files/customfeeds.conf create mode 100755 opkg/files/opkg-key create mode 100644 opkg/files/opkg-smime.conf create mode 100644 opkg/files/opkg.conf create mode 100644 ppp/Makefile create mode 100644 ppp/files/etc/ppp/chap-secrets create mode 100644 ppp/files/etc/ppp/filter create mode 100644 ppp/files/etc/ppp/options create mode 100644 ppp/files/etc/ppp/options.pptp create mode 100644 ppp/files/etc/ppp/radius.conf create mode 100644 ppp/files/etc/ppp/radius/dictionary create mode 100644 ppp/files/etc/ppp/radius/dictionary.asnet create mode 100644 ppp/files/etc/ppp/radius/dictionary.microsoft create mode 100644 ppp/files/etc/ppp/radius/servers create mode 100755 ppp/files/lib/netifd/ppp-down create mode 100755 ppp/files/lib/netifd/ppp-up create mode 100755 ppp/files/lib/netifd/ppp6-up create mode 100755 ppp/files/ppp.sh create mode 100644 ppp/patches/010-use_target_for_configure.patch create mode 100644 ppp/patches/105-debian_demand.patch create mode 100644 ppp/patches/120-debian_ipv6_updown_option.patch create mode 100644 ppp/patches/133-fix_sha1_include.patch create mode 100644 ppp/patches/200-makefile.patch create mode 100644 ppp/patches/201-mppe_mppc_1.1.patch create mode 100644 ppp/patches/203-opt_flags.patch create mode 100644 ppp/patches/204-radius_config.patch create mode 100644 ppp/patches/205-no_exponential_timeout.patch create mode 100644 ppp/patches/207-lcp_mtu_max.patch create mode 100644 ppp/patches/208-fix_status_code.patch create mode 100644 ppp/patches/300-filter-pcap-includes-lib.patch create mode 100644 ppp/patches/310-precompile_filter.patch create mode 100644 ppp/patches/321-multilink_support_custom_iface_names.patch create mode 100644 ppp/patches/330-retain_foreign_default_routes.patch create mode 100644 ppp/patches/340-populate_default_gateway.patch create mode 100644 ppp/patches/400-simplify_kernel_checks.patch create mode 100644 ppp/patches/401-no_record_file.patch create mode 100644 ppp/patches/403-no_wtmp.patch create mode 100644 ppp/patches/404-remove_obsolete_protocol_names.patch create mode 100644 ppp/patches/405-no_multilink_option.patch create mode 100644 ppp/patches/500-add-pptp-plugin.patch create mode 100644 ppp/patches/510-pptp_compile_fix.patch create mode 100644 ppp/patches/511-pptp_cflags.patch create mode 100644 ppp/patches/600-Revert-pppd-Use-openssl-for-the-DES-instead-of-the-l.patch create mode 100644 ppp/patches/610-pppd_compile_fix.patch create mode 100644 ppp/utils/pfc.c create mode 100644 ucl/Makefile create mode 100644 ucl/patches/001-autoconf-compat.patch create mode 100644 upx/Makefile create mode 100644 vsftpd-alt/Makefile create mode 100755 vsftpd-alt/files/vsftpd-uci.init create mode 100644 vsftpd-alt/files/vsftpd.conf create mode 100755 vsftpd-alt/files/vsftpd.init create mode 100644 vsftpd-alt/files/vsftpd.uci create mode 100755 vsftpd-alt/files/vsftpd_prepare create mode 100755 vsftpd-alt/files/vsftpd_wrapper create mode 100644 vsftpd-alt/patches/001-destdir.patch create mode 100644 vsftpd-alt/patches/002-find_libs.patch create mode 100644 vsftpd-alt/patches/003-chroot.patch create mode 100644 vsftpd-alt/patches/004-disable-capabilities.patch create mode 100644 vsftpd-alt/patches/005-disable-pam.patch create mode 100644 vsftpd-alt/patches/006-musl-compatibility.patch create mode 100644 vsftpd-alt/patches/007-CVE-2015-1419.patch create mode 100644 vsftpd-alt/patches/010-openssl-deprecated.patch create mode 100644 vsftpd-alt/patches/100-add-uci-auth-support.patch create mode 100644 vsftpd-alt/patches/101-enable-chroot-on-writable-dir.patch create mode 100644 vsftpd-alt/patches/102-keep-local-user-rights.patch create mode 100644 wireless-regdb/Makefile create mode 100644 wireless-regdb/patches/500-world-regd-5GHz.patch create mode 100644 wireless-regdb/patches/600-custom-change-txpower-and-dfs.patch diff --git a/base-files/Makefile b/base-files/Makefile new file mode 100644 index 000000000..8732f82fb --- /dev/null +++ b/base-files/Makefile @@ -0,0 +1,249 @@ +# +# Copyright (C) 2007-2021 OpenWrt.org +# Copyright (C) 2010 Vertical Communications +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/version.mk +include $(INCLUDE_DIR)/feeds.mk + +PKG_NAME:=base-files +PKG_FLAGS:=nonshared +PKG_RELEASE:=$(COMMITCOUNT) + +PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ +PKG_BUILD_DEPENDS:=usign/host ucert/host +PKG_LICENSE:=GPL-2.0 + +# Extend depends from version.mk +PKG_CONFIG_DEPENDS += \ + CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \ + CONFIG_NAND_SUPPORT \ + CONFIG_LEGACY_SDCARD_SUPPORT \ + CONFIG_EMMC_SUPPORT \ + CONFIG_CLEAN_IPKG \ + CONFIG_PER_FEED_REPO \ + $(foreach feed,$(FEEDS_AVAILABLE),CONFIG_FEED_$(feed)) + +include $(INCLUDE_DIR)/package.mk + +ifneq ($(DUMP),1) + STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | $(MKHASH) md5) + TARGET:=-$(BOARD) +endif + +define Package/base-files + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+netifd +libc +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:openwrt-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool + TITLE:=Base filesystem for OpenWrt + URL:=http://openwrt.org/ + VERSION:=$(PKG_RELEASE)-$(REVISION) +endef + +define Package/base-files/conffiles +/etc/config/ +/etc/config/network +/etc/config/system +/etc/dropbear/ +/etc/ethers +/etc/group +/etc/hosts +/etc/inittab +/etc/iproute2/rt_protos +/etc/iproute2/rt_tables +/etc/passwd +/etc/profile +/etc/profile.d +/etc/protocols +/etc/rc.local +/etc/services +/etc/shadow +/etc/shells +/etc/shinit +/etc/sysctl.conf +/etc/sysupgrade.conf +$(call $(TARGET)/conffiles) +endef + +define Package/base-files/description + This package contains a base filesystem and system scripts for OpenWrt. +endef + +define ImageConfigOptions + mkdir -p $(1)/lib/preinit + echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf + echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf + echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf +ifeq ($(CONFIG_TARGET_DEFAULT_LAN_IP_FROM_PREINIT),y) + mkdir -p $(1)/etc/board.d + echo '. /lib/functions/uci-defaults.sh' >$(1)/etc/board.d/99-lan-ip + echo 'logger -t 99-lan-ip "setting custom default LAN IP"' >>$(1)/etc/board.d/99-lan-ip + echo 'board_config_update' >>$(1)/etc/board.d/99-lan-ip + echo 'json_select network' >>$(1)/etc/board.d/99-lan-ip + echo 'json_select lan' >>$(1)/etc/board.d/99-lan-ip + echo 'json_add_string ipaddr $(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/etc/board.d/99-lan-ip + echo 'json_add_string netmask $(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/etc/board.d/99-lan-ip + echo 'json_select ..' >>$(1)/etc/board.d/99-lan-ip + echo 'json_select ..' >>$(1)/etc/board.d/99-lan-ip + echo 'board_config_flush' >>$(1)/etc/board.d/99-lan-ip +endif +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Compile/Default + +endef +Build/Compile = $(Build/Compile/Default) + +ifdef CONFIG_SIGNED_PACKAGES + define Build/Configure + [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \ + $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key" + + [ -s $(BUILD_KEY).ucert ] || \ + $(STAGING_DIR_HOST)/bin/ucert -I -c $(BUILD_KEY).ucert -p $(BUILD_KEY).pub -s $(BUILD_KEY) + + endef + +ifndef CONFIG_BUILDBOT + define Package/base-files/install-key + mkdir -p $(1)/etc/opkg/keys + $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub` + + endef +endif +endif + +ifeq ($(CONFIG_NAND_SUPPORT),) + define Package/base-files/nand-support + rm -f $(1)/lib/upgrade/nand.sh + endef +endif + +ifeq ($(CONFIG_EMMC_SUPPORT),) + define Package/base-files/emmc-support + rm -f $(1)/lib/upgrade/emmc.sh + endef +endif + +ifeq ($(CONFIG_LEGACY_SDCARD_SUPPORT),) + define Package/base-files/legacy-sdcard-support + rm -f $(1)/lib/upgrade/legacy-sdcard.sh + endef +endif + + +define Package/base-files/install + $(CP) ./files/* $(1)/ + $(Package/base-files/install-key) + $(Package/base-files/nand-support) + $(Package/base-files/legacy-sdcard-support) + $(Package/base-files/emmc-support) + if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \ + $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \ + fi + if [ -d $(PLATFORM_DIR)/base-files/. ]; then \ + $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \ + fi + $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \ + if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \ + $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \ + fi; \ + ) + + $(VERSION_SED_SCRIPT) \ + $(1)/etc/banner \ + $(1)/etc/device_info \ + $(1)/etc/openwrt_release \ + $(1)/etc/openwrt_version \ + $(1)/usr/lib/os-release + + + $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \ + $(1)/sbin/hotplug-call \ + $(1)/etc/preinit \ + $(1)/etc/profile + + mkdir -p \ + $(1)/CONTROL \ + $(1)/dev \ + $(1)/etc/config \ + $(1)/etc/crontabs \ + $(1)/etc/rc.d \ + $(1)/overlay \ + $(1)/lib/firmware \ + $(1)/mnt \ + $(1)/proc \ + $(1)/tmp \ + $(1)/usr/lib \ + $(1)/usr/bin \ + $(1)/sys \ + $(1)/www \ + $(1)/root + + $(LN) /proc/mounts $(1)/etc/mtab + $(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX)) + $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX)) + +ifneq ($(CONFIG_TARGET_ROOTFS_PERSIST_VAR),y) + rm -f $(1)/var + $(LN) tmp $(1)/var +else + mkdir -p $(1)/var + $(LN) /tmp/run $(1)/var/run +endif + $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/ + + chmod 0600 $(1)/etc/shadow + chmod 1777 $(1)/tmp + + $(call ImageConfigOptions,$(1)) + $(call Package/base-files/install-target,$(1)) + for conffile in $(1)/etc/config/*; do \ + if [ -f "$$$$conffile" ]; then \ + grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \ + echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \ + fi \ + done + + $(if $(CONFIG_INCLUDE_CONFIG), \ + echo -e "# Build configuration for board $(BOARD)/$(SUBTARGET)/$(PROFILE)\n" >$(1)/etc/build.config; \ + cat $(BIN_DIR)/config.buildinfo >>$(1)/etc/build.config; \ + cat $(BIN_DIR)/feeds.buildinfo >>$(1)/etc/build.feeds; \ + cat $(BIN_DIR)/version.buildinfo >>$(1)/etc/build.version) + + $(if $(CONFIG_CLEAN_IPKG),, \ + mkdir -p $(1)/etc/opkg; \ + $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf); \ + $(VERSION_SED_SCRIPT) $(1)/etc/opkg/distfeeds.conf) + $(if $(CONFIG_IPK_FILES_CHECKSUMS),, \ + rm -f $(1)/sbin/pkg_check) + + $(if $(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE), \ + rm -f $(1)/etc/banner.failsafe,) +endef + +ifneq ($(DUMP),1) + -include $(PLATFORM_DIR)/base-files.mk + -include $(PLATFORM_SUBDIR)/base-files.mk +endif + +$(eval $(call BuildPackage,base-files)) diff --git a/base-files/files/bin/board_detect b/base-files/files/bin/board_detect new file mode 100755 index 000000000..94f45bec5 --- /dev/null +++ b/base-files/files/bin/board_detect @@ -0,0 +1,14 @@ +#!/bin/sh + +CFG=$1 + +[ -n "$CFG" ] || CFG=/etc/board.json + +[ -d "/etc/board.d/" -a ! -s "$CFG" ] && { + for a in $(ls /etc/board.d/*); do + [ -s $a ] || continue; + $(. $a) + done +} + +[ -s "$CFG" ] || return 1 diff --git a/base-files/files/bin/config_generate b/base-files/files/bin/config_generate new file mode 100755 index 000000000..be21d0079 --- /dev/null +++ b/base-files/files/bin/config_generate @@ -0,0 +1,542 @@ +#!/bin/sh + +CFG=/etc/board.json + +. /usr/share/libubox/jshn.sh + +[ -s $CFG ] || /bin/board_detect || exit 1 +[ -s /etc/config/network -a -s /etc/config/system ] && exit 0 + +generate_bridge() { + local name=$1 + local macaddr=$2 + uci -q batch <<-EOF + set network.$name=device + set network.$name.name=$name + set network.$name.type=bridge + EOF + if [ -n "$macaddr" ]; then + uci -q batch <<-EOF + set network.$name.macaddr=$macaddr + EOF + fi +} + +bridge_vlan_id=0 +generate_bridge_vlan() { + local name=$1_vlan + local device=$2 + local ports="$3" + local vlan="$4" + uci -q batch <<-EOF + set network.$name=bridge-vlan + set network.$name.device='$device' + set network.$name.vlan='$vlan' + set network.$name.ports='$ports' + EOF +} + +generate_static_network() { + uci -q batch <<-EOF + delete network.loopback + set network.loopback='interface' + set network.loopback.device='lo' + set network.loopback.proto='static' + set network.loopback.ipaddr='127.0.0.1' + set network.loopback.netmask='255.0.0.0' + EOF + [ -e /proc/sys/net/ipv6 ] && { + uci -q batch <<-EOF + delete network.globals + set network.globals='globals' + set network.globals.ula_prefix='auto' + EOF + } + + if json_is_a dsl object; then + json_select dsl + if json_is_a atmbridge object; then + json_select atmbridge + local vpi vci encaps payload nameprefix + json_get_vars vpi vci encaps payload nameprefix + uci -q batch <<-EOF + delete network.atm + set network.atm='atm-bridge' + set network.atm.vpi='$vpi' + set network.atm.vci='$vci' + set network.atm.encaps='$encaps' + set network.atm.payload='$payload' + set network.atm.nameprefix='$nameprefix' + EOF + json_select .. + fi + + if json_is_a modem object; then + json_select modem + local type annex firmware tone xfer_mode + json_get_vars type annex firmware tone xfer_mode + uci -q batch <<-EOF + delete network.dsl + set network.dsl='dsl' + set network.dsl.annex='$annex' + set network.dsl.firmware='$firmware' + set network.dsl.tone='$tone' + set network.dsl.xfer_mode='$xfer_mode' + EOF + json_select .. + fi + json_select .. + fi +} + +addr_offset=2 +generate_network() { + local ports device macaddr protocol type ipaddr netmask vlan + local bridge=$2 + + json_select network + json_select "$1" + json_get_vars device macaddr metric protocol ipaddr netmask vlan + json_get_values ports ports + json_select .. + json_select .. + + [ -n "$device" -o -n "$ports" ] || return + + # Force bridge for "lan" as it may have other devices (e.g. wireless) + # bridged + [ "$1" = "lan" -a -z "$ports" ] && { + ports="$device" + } + + [ -n "$ports" -a -z "$bridge" ] && { + uci -q batch <<-EOF + add network device + set network.@device[-1].name='br-$1' + set network.@device[-1].type='bridge' + EOF + for port in $ports; do uci add_list network.@device[-1].ports="$port"; done + [ -n "$macaddr" ] && { + for port in $ports; do + uci -q batch <<-EOF + add network device + set network.@device[-1].name='$port' + set network.@device[-1].macaddr='$macaddr' + EOF + done + } + device=br-$1 + type= + macaddr="" + } + + [ -n "$bridge" ] && { + [ -z "$ports" ] && ports="$device" + if [ -z "$vlan" ]; then + bridge_vlan_id=$((bridge_vlan_id + 1)) + vlan=$bridge_vlan_id + fi + generate_bridge_vlan $1 $bridge "$ports" $vlan + device=$bridge.$vlan + type="" + } + + if [ -n "$macaddr" ]; then + uci -q batch <<-EOF + add network device + set network.@device[-1].name='$device' + set network.@device[-1].macaddr='$macaddr' + EOF + fi + + uci -q batch <<-EOF + delete network.$1 + set network.$1='interface' + set network.$1.type='$type' + set network.$1.device='$device' + set network.$1.metric='$metric' + set network.$1.proto='none' + EOF + + case "$protocol" in + static) + local ipad + case "$1" in + lan) ipad=${ipaddr:-"192.168.1.1"} ;; + *) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;; + esac + + netm=${netmask:-"255.255.255.0"} + + uci -q batch <<-EOF + set network.$1.proto='static' + set network.$1.ipaddr='$ipad' + set network.$1.netmask='$netm' + EOF + [ -e /proc/sys/net/ipv6 ] && uci set network.$1.ip6assign='60' + ;; + + dhcp) + # fixup IPv6 slave interface if parent is a bridge + [ "$type" = "bridge" ] && device="br-$1" + + uci set network.$1.proto='dhcp' + [ -e /proc/sys/net/ipv6 ] && { + uci -q batch <<-EOF + delete network.${1}6 + set network.${1}6='interface' + set network.${1}6.device='$device' + set network.${1}6.proto='dhcpv6' + EOF + } + ;; + + pppoe) + uci -q batch <<-EOF + set network.$1.proto='pppoe' + set network.$1.username='username' + set network.$1.password='password' + EOF + [ -e /proc/sys/net/ipv6 ] && { + uci -q batch <<-EOF + set network.$1.ipv6='1' + delete network.${1}6 + set network.${1}6='interface' + set network.${1}6.device='@${1}' + set network.${1}6.proto='dhcpv6' + EOF + } + ;; + + ncm|\ + qmi|\ + mbim) + uci -q batch <<-EOF + set network.$1.proto='${protocol}' + set network.$1.pdptype='ipv4' + EOF + ;; + esac +} + +generate_switch_vlans_ports() { + local switch="$1" + local port ports role roles num attr val + + # + # autogenerate vlans + # + + if json_is_a roles array; then + json_get_keys roles roles + json_select roles + + for role in $roles; do + json_select "$role" + json_get_vars ports + json_select .. + + uci -q batch <<-EOF + add network switch_vlan + set network.@switch_vlan[-1].device='$switch' + set network.@switch_vlan[-1].vlan='$role' + set network.@switch_vlan[-1].ports='$ports' + EOF + done + + json_select .. + fi + + + # + # write port specific settings + # + + if json_is_a ports array; then + json_get_keys ports ports + json_select ports + + for port in $ports; do + json_select "$port" + json_get_vars num + + if json_is_a attr object; then + json_get_keys attr attr + json_select attr + uci -q batch <<-EOF + add network switch_port + set network.@switch_port[-1].device='$switch' + set network.@switch_port[-1].port=$num + EOF + + for attr in $attr; do + json_get_var val "$attr" + uci -q set network.@switch_port[-1].$attr="$val" + done + json_select .. + fi + json_select .. + done + + json_select .. + fi +} + +generate_switch() { + local key="$1" + local vlans + + json_select switch + json_select "$key" + json_get_vars enable reset blinkrate cpu_port \ + ar8xxx_mib_type ar8xxx_mib_poll_interval + + uci -q batch <<-EOF + add network switch + set network.@switch[-1].name='$key' + set network.@switch[-1].reset='$reset' + set network.@switch[-1].enable_vlan='$enable' + set network.@switch[-1].blinkrate='$blinkrate' + set network.@switch[-1].ar8xxx_mib_type='$ar8xxx_mib_type' + set network.@switch[-1].ar8xxx_mib_poll_interval='$ar8xxx_mib_poll_interval' + EOF + + generate_switch_vlans_ports "$1" + + json_select .. + json_select .. +} + +generate_static_system() { + uci -q batch <<-EOF + delete system.@system[0] + add system system + set system.@system[-1].hostname='OpenWrt' + set system.@system[-1].timezone='UTC' + set system.@system[-1].ttylogin='0' + set system.@system[-1].log_size='64' + set system.@system[-1].urandom_seed='0' + + delete system.ntp + set system.ntp='timeserver' + set system.ntp.enabled='1' + set system.ntp.enable_server='0' + add_list system.ntp.server='0.openwrt.pool.ntp.org' + add_list system.ntp.server='1.openwrt.pool.ntp.org' + add_list system.ntp.server='2.openwrt.pool.ntp.org' + add_list system.ntp.server='3.openwrt.pool.ntp.org' + EOF + + if json_is_a system object; then + json_select system + local hostname + if json_get_var hostname hostname; then + uci -q set "system.@system[-1].hostname=$hostname" + fi + + local compat_version + if json_get_var compat_version compat_version; then + uci -q set "system.@system[-1].compat_version=$compat_version" + else + uci -q set "system.@system[-1].compat_version=1.0" + fi + + if json_is_a ntpserver array; then + local keys key + json_get_keys keys ntpserver + json_select ntpserver + uci -q delete "system.ntp.server" + + for key in $keys; do + local server + if json_get_var server "$key"; then + uci -q add_list "system.ntp.server=$server" + fi + done + json_select .. + fi + json_select .. + fi +} + +generate_rssimon() { + local key="$1" + local cfg="rssid_$key" + local refresh threshold + + json_select rssimon + json_select "$key" + json_get_vars refresh threshold + json_select .. + json_select .. + + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='rssid' + set system.$cfg.dev='$key' + set system.$cfg.refresh='$refresh' + set system.$cfg.threshold='$threshold' + EOF +} + +generate_led() { + local key="$1" + local cfg="led_$key" + + json_select led + json_select "$key" + json_get_vars name sysfs type trigger default + + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='led' + set system.$cfg.name='$name' + set system.$cfg.sysfs='$sysfs' + set system.$cfg.trigger='$trigger' + set system.$cfg.default='$default' + EOF + + case "$type" in + gpio) + local gpio inverted + json_get_vars gpio inverted + uci -q batch <<-EOF + set system.$cfg.trigger='gpio' + set system.$cfg.gpio='$gpio' + set system.$cfg.inverted='$inverted' + EOF + ;; + + netdev) + local device mode + json_get_vars device mode + uci -q batch <<-EOF + set system.$cfg.trigger='netdev' + set system.$cfg.mode='$mode' + set system.$cfg.dev='$device' + EOF + ;; + + usb) + local device + json_get_vars device + uci -q batch <<-EOF + set system.$cfg.trigger='usbdev' + set system.$cfg.interval='50' + set system.$cfg.dev='$device' + EOF + ;; + + usbport) + local ports port + json_get_values ports ports + uci set system.$cfg.trigger='usbport' + for port in $ports; do + uci add_list system.$cfg.port=$port + done + ;; + + rssi) + local iface minq maxq offset factor + json_get_vars iface minq maxq offset factor + uci -q batch <<-EOF + set system.$cfg.trigger='rssi' + set system.$cfg.iface='rssid_$iface' + set system.$cfg.minq='$minq' + set system.$cfg.maxq='$maxq' + set system.$cfg.offset='$offset' + set system.$cfg.factor='$factor' + EOF + ;; + + switch) + local port_mask speed_mask mode + json_get_vars port_mask speed_mask mode + uci -q batch <<-EOF + set system.$cfg.port_mask='$port_mask' + set system.$cfg.speed_mask='$speed_mask' + set system.$cfg.mode='$mode' + EOF + ;; + + portstate) + local port_state + json_get_vars port_state + uci -q batch <<-EOF + set system.$cfg.port_state='$port_state' + EOF + ;; + + timer|oneshot) + local delayon delayoff + json_get_vars delayon delayoff + uci -q batch <<-EOF + set system.$cfg.trigger='$type' + set system.$cfg.delayon='$delayon' + set system.$cfg.delayoff='$delayoff' + EOF + ;; + esac + + json_select .. + json_select .. +} + +generate_gpioswitch() { + local cfg="$1" + + json_select gpioswitch + json_select "$cfg" + local name pin default + json_get_vars name pin default + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='gpio_switch' + set system.$cfg.name='$name' + set system.$cfg.gpio_pin='$pin' + set system.$cfg.value='$default' + EOF + json_select .. + json_select .. +} + +json_init +json_load "$(cat ${CFG})" + +umask 077 + +if [ ! -s /etc/config/network ]; then + bridge_name="" + touch /etc/config/network + generate_static_network + + json_get_vars bridge + [ -n "$bridge" ] && { + json_select bridge + json_get_vars name macaddr + generate_bridge "$name" "$macaddr" + json_select .. + bridge_name=$name + } + + json_get_keys keys network + for key in $keys; do generate_network $key $bridge_name; done + + json_get_keys keys switch + for key in $keys; do generate_switch $key; done +fi + +if [ ! -s /etc/config/system ]; then + touch /etc/config/system + generate_static_system + + json_get_keys keys rssimon + for key in $keys; do generate_rssimon $key; done + + json_get_keys keys gpioswitch + for key in $keys; do generate_gpioswitch $key; done + + json_get_keys keys led + for key in $keys; do generate_led $key; done +fi +uci commit diff --git a/base-files/files/bin/ipcalc.sh b/base-files/files/bin/ipcalc.sh new file mode 100755 index 000000000..6e72617e1 --- /dev/null +++ b/base-files/files/bin/ipcalc.sh @@ -0,0 +1,88 @@ +#!/usr/bin/awk -f + +function bitcount(c) { + c=and(rshift(c, 1),0x55555555)+and(c,0x55555555) + c=and(rshift(c, 2),0x33333333)+and(c,0x33333333) + c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f) + c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff) + c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff) + return c +} + +function ip2int(ip) { + ret=0 + n=split(ip,a,"\\.") + for (x=1;x<=n;x++) + ret=or(lshift(ret,8),a[x]) + return ret +} + +function int2ip(ip,ret,x) { + ret=and(ip,255) + ip=rshift(ip,8) + for(;x<3;x++) { + ret=and(ip,255)"."ret + ip=rshift(ip,8) + } + return ret +} + +function compl32(v) { + ret=xor(v, 0xffffffff) + return ret +} + +BEGIN { + slpos=index(ARGV[1],"/") + if (slpos == 0) { + ipaddr=ip2int(ARGV[1]) + dotpos=index(ARGV[2],".") + if (dotpos == 0) + netmask=compl32(2**(32-int(ARGV[2]))-1) + else + netmask=ip2int(ARGV[2]) + } else { + ipaddr=ip2int(substr(ARGV[1],0,slpos-1)) + netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1) + ARGV[4]=ARGV[3] + ARGV[3]=ARGV[2] + } + + network=and(ipaddr,netmask) + prefix=32-bitcount(compl32(netmask)) + broadcast=or(network,compl32(netmask)) + + print "IP="int2ip(ipaddr) + print "NETMASK="int2ip(netmask) + print "BROADCAST="int2ip(broadcast) + print "NETWORK="int2ip(network) + print "PREFIX="prefix + + # range calculations: + # ipcalc + + if (ARGC <= 3) + exit(0) + + start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) + limit=network+1 + if (startlimit) end=limit + if (end==ipaddr) end=ipaddr-1 + + if (start>end) { + print "network ("int2ip(network)"/"prefix") too small" > "/dev/stderr" + exit(1) + } + + if (ipaddr > start && ipaddr < end) { + print "warning: ipaddr inside range - this might not be supported in future releases of Openwrt" > "/dev/stderr" + } + + print "START="int2ip(start) + print "END="int2ip(end) +} diff --git a/base-files/files/etc/banner b/base-files/files/etc/banner new file mode 100644 index 000000000..f3af3c014 --- /dev/null +++ b/base-files/files/etc/banner @@ -0,0 +1,8 @@ + _______ ________ __ + | |.-----.-----.-----.| | | |.----.| |_ + | - || _ | -__| || | | || _|| _| + |_______|| __|_____|__|__||________||__| |____| + |__| W I R E L E S S F R E E D O M + ----------------------------------------------------- + %D %V, %C + ----------------------------------------------------- diff --git a/base-files/files/etc/banner.failsafe b/base-files/files/etc/banner.failsafe new file mode 100644 index 000000000..49855e713 --- /dev/null +++ b/base-files/files/etc/banner.failsafe @@ -0,0 +1,15 @@ +================= FAILSAFE MODE active ================ +special commands: +* firstboot reset settings to factory defaults +* mount_root mount root-partition with config files + +after mount_root: +* passwd change root's password +* /etc/config directory with config files + +for more help see: +https://openwrt.org/docs/guide-user/troubleshooting/ +- failsafe_and_factory_reset +- root_password_reset +======================================================= + diff --git a/base-files/files/etc/board.d/99-default_network b/base-files/files/etc/board.d/99-default_network new file mode 100644 index 000000000..49d2a3b35 --- /dev/null +++ b/base-files/files/etc/board.d/99-default_network @@ -0,0 +1,16 @@ +# +# Copyright (C) 2013-2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh + +board_config_update + +json_is_a network object && exit 0 + +ucidef_set_interface_lan 'eth0' +[ -d /sys/class/net/eth1 ] && ucidef_set_interface_wan 'eth1' + +board_config_flush + +exit 0 diff --git a/base-files/files/etc/device_info b/base-files/files/etc/device_info new file mode 100644 index 000000000..4045e9e02 --- /dev/null +++ b/base-files/files/etc/device_info @@ -0,0 +1,4 @@ +DEVICE_MANUFACTURER='%M' +DEVICE_MANUFACTURER_URL='%m' +DEVICE_PRODUCT='%P' +DEVICE_REVISION='%h' diff --git a/base-files/files/etc/diag.sh b/base-files/files/etc/diag.sh new file mode 100644 index 000000000..37a8ec758 --- /dev/null +++ b/base-files/files/etc/diag.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Copyright (C) 2006-2019 OpenWrt.org + +. /lib/functions/leds.sh + +boot="$(get_dt_led boot)" +failsafe="$(get_dt_led failsafe)" +running="$(get_dt_led running)" +upgrade="$(get_dt_led upgrade)" + +set_led_state() { + status_led="$boot" + + case "$1" in + preinit) + status_led_blink_preinit + ;; + failsafe) + status_led_off + [ -n "$running" ] && { + status_led="$running" + status_led_off + } + status_led="$failsafe" + status_led_blink_failsafe + ;; + preinit_regular) + status_led_blink_preinit_regular + ;; + upgrade) + [ -n "$running" ] && { + status_led="$running" + status_led_off + } + status_led="$upgrade" + status_led_blink_preinit_regular + ;; + done) + status_led_off + [ "$status_led" != "$running" ] && \ + status_led_restore_trigger "boot" + [ -n "$running" ] && { + status_led="$running" + status_led_on + } + ;; + esac +} + +set_state() { + [ -n "$boot" -o -n "$failsafe" -o -n "$running" -o -n "$upgrade" ] && set_led_state "$1" +} diff --git a/base-files/files/etc/ethers b/base-files/files/etc/ethers new file mode 100644 index 000000000..b92c200a4 --- /dev/null +++ b/base-files/files/etc/ethers @@ -0,0 +1,6 @@ +# +# Lookup man 5 ethers for syntax documentation +# +# Examples : +# 02:00:11:22:33:44 OpenWrt.lan +# 02:00:11:22:33:44 192.168.1.1 diff --git a/base-files/files/etc/fstab b/base-files/files/etc/fstab new file mode 100644 index 000000000..6e9b7baf5 --- /dev/null +++ b/base-files/files/etc/fstab @@ -0,0 +1 @@ +# diff --git a/base-files/files/etc/group b/base-files/files/etc/group new file mode 100644 index 000000000..5b06dc6db --- /dev/null +++ b/base-files/files/etc/group @@ -0,0 +1,11 @@ +root:x:0: +daemon:x:1: +adm:x:4: +mail:x:8: +dialout:x:20: +audio:x:29: +www-data:x:33: +ftp:x:55: +users:x:100: +network:x:101: +nogroup:x:65534: diff --git a/base-files/files/etc/hosts b/base-files/files/etc/hosts new file mode 100644 index 000000000..b7713ebcc --- /dev/null +++ b/base-files/files/etc/hosts @@ -0,0 +1,5 @@ +127.0.0.1 localhost + +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/base-files/files/etc/hotplug.d/net/00-sysctl b/base-files/files/etc/hotplug.d/net/00-sysctl new file mode 100644 index 000000000..8abe7f8bb --- /dev/null +++ b/base-files/files/etc/hotplug.d/net/00-sysctl @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$ACTION" = add ]; then + for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do + [ ! -f "$CONF" ] && continue; + sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" "$CONF" | \ + sysctl -e -p - | logger -t sysctl + done +fi diff --git a/base-files/files/etc/init.d/boot b/base-files/files/etc/init.d/boot new file mode 100755 index 000000000..749d9e971 --- /dev/null +++ b/base-files/files/etc/init.d/boot @@ -0,0 +1,55 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=90 + +uci_apply_defaults() { + . /lib/functions/system.sh + + cd /etc/uci-defaults || return 0 + files="$(ls)" + [ -z "$files" ] && return 0 + mkdir -p /tmp/.uci + for file in $files; do + ( . "./$(basename $file)" ) && rm -f "$file" + done + uci commit +} + +boot() { + [ -f /proc/mounts ] || /sbin/mount_root + [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc + + mkdir -p /var/lock + chmod 1777 /var/lock + mkdir -p /var/log + mkdir -p /var/run + mkdir -p /var/state + mkdir -p /var/tmp + mkdir -p /tmp/.uci + chmod 0700 /tmp/.uci + touch /var/log/wtmp + touch /var/log/lastlog + mkdir -p /tmp/resolv.conf.d + touch /tmp/resolv.conf.d/resolv.conf.auto + ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf + grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug + grep -q bpf /proc/filesystems && /bin/mount -o nosuid,nodev,noexec,noatime,mode=0700 -t bpf bpffs /sys/fs/bpf + grep -q pstore /proc/filesystems && /bin/mount -o noatime -t pstore pstore /sys/fs/pstore + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + /sbin/kmodloader + + [ ! -f /etc/config/wireless ] && { + # compat for bcm47xx and mvebu + sleep 1 + } + + /bin/config_generate + uci_apply_defaults + sync + + # temporary hack until configd exists + /sbin/reload_config +} diff --git a/base-files/files/etc/init.d/done b/base-files/files/etc/init.d/done new file mode 100755 index 000000000..32d6118df --- /dev/null +++ b/base-files/files/etc/init.d/done @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + mount_root done + rm -f /sysupgrade.tgz && sync + + # process user commands + [ -f /etc/rc.local ] && { + sh /etc/rc.local + } + + # set leds to normal state + . /etc/diag.sh + set_state done +} diff --git a/base-files/files/etc/init.d/gpio_switch b/base-files/files/etc/init.d/gpio_switch new file mode 100755 index 000000000..24d790b06 --- /dev/null +++ b/base-files/files/etc/init.d/gpio_switch @@ -0,0 +1,66 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2015 OpenWrt.org + +START=94 +STOP=10 +USE_PROCD=1 + + +load_gpio_switch() +{ + local name + local gpio_pin + local value + + config_get gpio_pin "$1" gpio_pin + config_get name "$1" name + config_get value "$1" value 0 + + [ -z "$gpio_pin" ] && { + echo >&2 "Skipping gpio_switch '$name' due to missing gpio_pin" + return 1 + } + + local gpio_path + if [ -n "$(echo "$gpio_pin" | grep -E "^[0-9]+$")" ]; then + gpio_path="/sys/class/gpio/gpio${gpio_pin}" + + # export GPIO pin for access + [ -d "$gpio_path" ] || { + echo "$gpio_pin" >/sys/class/gpio/export + # we need to wait a bit until the GPIO appears + [ -d "$gpio_path" ] || sleep 1 + } + + # direction attribute only exists if the kernel supports changing the + # direction of a GPIO + if [ -e "${gpio_path}/direction" ]; then + # set the pin to output with high or low pin value + { [ "$value" = "0" ] && echo "low" || echo "high"; } \ + >"$gpio_path/direction" + else + { [ "$value" = "0" ] && echo "0" || echo "1"; } \ + >"$gpio_path/value" + fi + else + gpio_path="/sys/class/gpio/${gpio_pin}" + + [ -d "$gpio_path" ] && { + { [ "$value" = "0" ] && echo "0" || echo "1"; } \ + >"$gpio_path/value" + } + fi +} + +service_triggers() +{ + procd_add_reload_trigger "system" +} + +start_service() +{ + [ -e /sys/class/gpio/ ] && { + config_load system + config_foreach load_gpio_switch gpio_switch + } +} diff --git a/base-files/files/etc/init.d/led b/base-files/files/etc/init.d/led new file mode 100755 index 000000000..08a1e6df3 --- /dev/null +++ b/base-files/files/etc/init.d/led @@ -0,0 +1,145 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008 OpenWrt.org + +START=96 + +load_led() { + local name + local sysfs + local trigger + local dev + local ports + local mode + local default + local delayon + local delayoff + local interval + + config_get sysfs $1 sysfs + config_get name $1 name "$sysfs" + config_get trigger $1 trigger "none" + config_get dev $1 dev + config_get ports $1 port + config_get mode $1 mode + config_get_bool default $1 default "0" + config_get delayon $1 delayon + config_get delayoff $1 delayoff + config_get interval $1 interval "50" + config_get port_state $1 port_state + config_get delay $1 delay "150" + config_get message $1 message "" + config_get gpio $1 gpio "0" + config_get_bool inverted $1 inverted "0" + + # execute application led trigger + [ -f "/usr/libexec/led-trigger/${trigger}" ] && { + . "/usr/libexec/led-trigger/${trigger}" + return 0 + } + + [ "$trigger" = "usbdev" ] && { + # Backward compatibility: translate to the new trigger + trigger="usbport" + # Translate port of root hub, e.g. 4-1 -> usb4-port1 + ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p') + # Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4 + [ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p') + } + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + + printf "%s %s %d\n" \ + "$sysfs" \ + "$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \ + "$(cat /sys/class/leds/${sysfs}/brightness)" \ + >> /var/run/led.state + + [ "$default" = 0 ] && + echo 0 >/sys/class/leds/${sysfs}/brightness + + echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null + ret="$?" + + [ $default = 1 ] && + cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness + + [ $ret = 0 ] || { + echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module" + return 1 + } + case "$trigger" in + "heartbeat") + echo "${inverted}" > "/sys/class/leds/${sysfs}/invert" + ;; + + "netdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + for m in $mode; do + [ -e "/sys/class/leds/${sysfs}/$m" ] && \ + echo 1 > /sys/class/leds/${sysfs}/$m + done + echo $interval > /sys/class/leds/${sysfs}/interval + } + ;; + + "timer"|"oneshot") + [ -n "$delayon" ] && \ + echo $delayon > /sys/class/leds/${sysfs}/delay_on + [ -n "$delayoff" ] && \ + echo $delayoff > /sys/class/leds/${sysfs}/delay_off + ;; + + "usbport") + local p + + for p in $ports; do + echo 1 > /sys/class/leds/${sysfs}/ports/$p + done + ;; + + "port_state") + [ -n "$port_state" ] && \ + echo $port_state > /sys/class/leds/${sysfs}/port_state + ;; + + "gpio") + echo $gpio > /sys/class/leds/${sysfs}/gpio + echo $inverted > /sys/class/leds/${sysfs}/inverted + ;; + + switch[0-9]*) + local port_mask speed_mask + + config_get port_mask $1 port_mask + [ -n "$port_mask" ] && \ + echo $port_mask > /sys/class/leds/${sysfs}/port_mask + config_get speed_mask $1 speed_mask + [ -n "$speed_mask" ] && \ + echo $speed_mask > /sys/class/leds/${sysfs}/speed_mask + [ -n "$mode" ] && \ + echo "$mode" > /sys/class/leds/${sysfs}/mode + ;; + esac + } +} + +start() { + [ -e /sys/class/leds/ ] && { + [ -s /var/run/led.state ] && { + local led trigger brightness + while read led trigger brightness; do + [ -e "/sys/class/leds/$led/trigger" ] && \ + echo "$trigger" > "/sys/class/leds/$led/trigger" + + [ -e "/sys/class/leds/$led/brightness" ] && \ + echo "$brightness" > "/sys/class/leds/$led/brightness" + done < /var/run/led.state + rm /var/run/led.state + } + + config_load system + config_foreach load_led led + } +} diff --git a/base-files/files/etc/init.d/sysctl b/base-files/files/etc/init.d/sysctl new file mode 100755 index 000000000..4db56444c --- /dev/null +++ b/base-files/files/etc/init.d/sysctl @@ -0,0 +1,44 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=11 + +apply_defaults() { + local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)" + local min_free frag_low_thresh frag_high_thresh + + if [ "$mem" -gt 65536 ]; then # 128M + min_free=16384 + elif [ "$mem" -gt 32768 ]; then # 64M + min_free=8192 + else + min_free=1024 + frag_low_thresh=393216 + frag_high_thresh=524288 + fi + + sysctl -qw vm.min_free_kbytes="$min_free" + + [ "$frag_low_thresh" ] && sysctl -qw \ + net.ipv4.ipfrag_low_thresh="$frag_low_thresh" \ + net.ipv4.ipfrag_high_thresh="$frag_high_thresh" \ + net.ipv6.ip6frag_low_thresh="$frag_low_thresh" \ + net.ipv6.ip6frag_high_thresh="$frag_high_thresh" \ + net.netfilter.nf_conntrack_frag6_low_thresh="$frag_low_thresh" \ + net.netfilter.nf_conntrack_frag6_high_thresh="$frag_high_thresh" + + # first set default, then all interfaces to avoid races with appearing interfaces + if [ -d /proc/sys/net/ipv6/conf ]; then + echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra + for iface in /proc/sys/net/ipv6/conf/*/accept_ra; do + echo 0 > "$iface" + done + fi +} + +start() { + apply_defaults + for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do + [ -f "$CONF" ] && sysctl -e -p "$CONF" >&- + done +} diff --git a/base-files/files/etc/init.d/sysfixtime b/base-files/files/etc/init.d/sysfixtime new file mode 100755 index 000000000..93f792266 --- /dev/null +++ b/base-files/files/etc/init.d/sysfixtime @@ -0,0 +1,44 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013-2014 OpenWrt.org + +START=00 +STOP=90 + +RTC_DEV=/dev/rtc0 +HWCLOCK=/sbin/hwclock + +boot() { + hwclock_load + local maxtime="$(find_max_time)" + local curtime="$(date +%s)" + if [ $curtime -lt $maxtime ]; then + date -s @$maxtime + hwclock_save + fi +} + +start() { + hwclock_load +} + +stop() { + hwclock_save +} + +hwclock_load() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -u -f $RTC_DEV +} + +hwclock_save(){ + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -u -f $RTC_DEV && \ + logger -t sysfixtime "saved '$(date)' to $RTC_DEV" +} + +find_max_time() { + local file newest + + for file in $( find /etc -type f ) ; do + [ -z "$newest" -o "$newest" -ot "$file" ] && newest=$file + done + [ "$newest" ] && date -r "$newest" +%s +} diff --git a/base-files/files/etc/init.d/system b/base-files/files/etc/init.d/system new file mode 100755 index 000000000..dcfc2616c --- /dev/null +++ b/base-files/files/etc/init.d/system @@ -0,0 +1,45 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 OpenWrt.org + +START=10 +USE_PROCD=1 + +validate_system_section() { + uci_load_validate system system "$1" "$2" \ + 'hostname:string:OpenWrt' \ + 'conloglevel:uinteger' \ + 'buffersize:uinteger' \ + 'timezone:string:UTC' \ + 'zonename:string' +} + +system_config() { + [ "$2" = 0 ] || { + echo "validation failed" + return 1 + } + + echo "$hostname" > /proc/sys/kernel/hostname + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + echo "$timezone" > /tmp/TZ + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/${zonename// /_}" ] \ + && ln -sf "/usr/share/zoneinfo/${zonename// /_}" /tmp/localtime \ + && rm -f /tmp/TZ + + # apply timezone to kernel + hwclock -u --systz +} + +reload_service() { + config_load system + config_foreach validate_system_section system system_config +} + +service_triggers() { + procd_add_reload_trigger "system" + procd_add_validation validate_system_section +} + +start_service() { + reload_service +} diff --git a/base-files/files/etc/init.d/umount b/base-files/files/etc/init.d/umount new file mode 100755 index 000000000..b764ae158 --- /dev/null +++ b/base-files/files/etc/init.d/umount @@ -0,0 +1,13 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +STOP=90 + +restart() { + : +} + +stop() { + sync + /bin/umount -a -d -r +} diff --git a/base-files/files/etc/inittab b/base-files/files/etc/inittab new file mode 100644 index 000000000..9820e7144 --- /dev/null +++ b/base-files/files/etc/inittab @@ -0,0 +1,3 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +::askconsole:/usr/libexec/login.sh diff --git a/base-files/files/etc/iproute2/ematch_map b/base-files/files/etc/iproute2/ematch_map new file mode 100644 index 000000000..4d6bb2f03 --- /dev/null +++ b/base-files/files/etc/iproute2/ematch_map @@ -0,0 +1,8 @@ +# lookup table for ematch kinds +1 cmp +2 nbyte +3 u32 +4 meta +7 canid +8 ipset +9 ipt diff --git a/base-files/files/etc/iproute2/rt_protos b/base-files/files/etc/iproute2/rt_protos new file mode 100644 index 000000000..5b61798ae --- /dev/null +++ b/base-files/files/etc/iproute2/rt_protos @@ -0,0 +1,18 @@ +# +# Reserved protocols. +# +0 unspec +1 redirect +2 kernel +3 boot +4 static +8 gated +9 ra +10 mrt +11 zebra +12 bird +13 dnrouted +14 xorp +15 ntk +16 dhcp +42 babel diff --git a/base-files/files/etc/iproute2/rt_tables b/base-files/files/etc/iproute2/rt_tables new file mode 100644 index 000000000..5fc09b3c0 --- /dev/null +++ b/base-files/files/etc/iproute2/rt_tables @@ -0,0 +1,12 @@ +# +# reserved values +# +128 prelocal +255 local +254 main +253 default +0 unspec +# +# local +# +#1 inr.ruhep diff --git a/base-files/files/etc/openwrt_release b/base-files/files/etc/openwrt_release new file mode 100644 index 000000000..d03400ca0 --- /dev/null +++ b/base-files/files/etc/openwrt_release @@ -0,0 +1,7 @@ +DISTRIB_ID='%D' +DISTRIB_RELEASE='%V' +DISTRIB_REVISION='%R' +DISTRIB_TARGET='%S' +DISTRIB_ARCH='%A' +DISTRIB_DESCRIPTION='%D %V %C' +DISTRIB_TAINTS='%t' diff --git a/base-files/files/etc/openwrt_version b/base-files/files/etc/openwrt_version new file mode 100644 index 000000000..48157ed97 --- /dev/null +++ b/base-files/files/etc/openwrt_version @@ -0,0 +1 @@ +%C diff --git a/base-files/files/etc/os-release b/base-files/files/etc/os-release new file mode 120000 index 000000000..c4c75b419 --- /dev/null +++ b/base-files/files/etc/os-release @@ -0,0 +1 @@ +../usr/lib/os-release \ No newline at end of file diff --git a/base-files/files/etc/passwd b/base-files/files/etc/passwd new file mode 100644 index 000000000..1d06a8036 --- /dev/null +++ b/base-files/files/etc/passwd @@ -0,0 +1,5 @@ +root:x:0:0:root:/root:/bin/ash +daemon:*:1:1:daemon:/var:/bin/false +ftp:*:55:55:ftp:/home/ftp:/bin/false +network:*:101:101:network:/var:/bin/false +nobody:*:65534:65534:nobody:/var:/bin/false diff --git a/base-files/files/etc/preinit b/base-files/files/etc/preinit new file mode 100755 index 000000000..829574f5f --- /dev/null +++ b/base-files/files/etc/preinit @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2006-2016 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +[ -z "$PREINIT" ] && exec /sbin/init + +export PATH="%PATH%" + +. /lib/functions.sh +. /lib/functions/preinit.sh +. /lib/functions/system.sh + +boot_hook_init preinit_essential +boot_hook_init preinit_main +boot_hook_init failsafe +boot_hook_init initramfs +boot_hook_init preinit_mount_root + +for pi_source_file in /lib/preinit/*; do + . $pi_source_file +done + +boot_run_hook preinit_essential + +pi_mount_skip_next=false +pi_jffs2_mount_success=false +pi_failsafe_net_message=false + +boot_run_hook preinit_main diff --git a/base-files/files/etc/profile b/base-files/files/etc/profile new file mode 100644 index 000000000..76b149b9f --- /dev/null +++ b/base-files/files/etc/profile @@ -0,0 +1,40 @@ +[ -e /tmp/.failsafe ] && export FAILSAFE=1 + +[ -f /etc/banner ] && cat /etc/banner +[ -n "$FAILSAFE" ] && cat /etc/banner.failsafe + +grep -Fsq '/ overlay ro,' /proc/mounts && { + echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.' + echo 'Please try to remove files from /overlay/upper/... and reboot!' +} + +export PATH="%PATH%" +export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6) +export HOME=${HOME:-/root} +export PS1='\u@\h:\w\$ ' +export ENV=/etc/shinit + +case "$TERM" in + xterm*|rxvt*) + export PS1='\[\e]0;\u@\h: \w\a\]'$PS1 + ;; +esac + +[ -n "$FAILSAFE" ] || { + for FILE in /etc/profile.d/*.sh; do + [ -e "$FILE" ] && . "$FILE" + done + unset FILE +} + +if ( grep -qs '^root::' /etc/shadow && \ + [ -z "$FAILSAFE" ] ) +then +cat << EOF +=== WARNING! ===================================== +There is no root password defined on this device! +Use the "passwd" command to set up a new password +in order to prevent unauthorized SSH logins. +-------------------------------------------------- +EOF +fi diff --git a/base-files/files/etc/protocols b/base-files/files/etc/protocols new file mode 100644 index 000000000..26bc775ed --- /dev/null +++ b/base-files/files/etc/protocols @@ -0,0 +1,57 @@ +# Internet (IP) protocols +# +# Updated from http://www.iana.org/assignments/protocol-numbers and other +# sources. +# New protocols will be added on request if they have been officially +# assigned by IANA and are not historical. +# If you need a huge list of used numbers please install the nmap package. + +ip 0 IP # internet protocol, pseudo protocol number +#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883] +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +igp 9 IGP # any private interior gateway (Cisco) +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905] +dccp 33 DCCP # Datagram Congestion Control Protocol [RFC4340] +xtp 36 XTP # Xpress Transfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # Internet Protocol, version 6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 IPSEC-ESP # Encap Security Payload [RFC2046] +ah 51 IPSEC-AH # Authentication Header [RFC2402] +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB) +vmtp 81 VMTP # Versatile Message Transport +eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) +ospf 89 OSPFIGP # Open Shortest Path First IGP +ax.25 93 AX.25 # AX.25 frames +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378] +encap 98 ENCAP # Yet Another IP encapsulation [RFC1241] +# 99 # any private encryption scheme +pim 103 PIM # Protocol Independent Multicast +ipcomp 108 IPCOMP # IP Payload Compression Protocol +vrrp 112 VRRP # Virtual Router Redundancy Protocol +l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661] +isis 124 ISIS # IS-IS over IPv4 +sctp 132 SCTP # Stream Control Transmission Protocol +fc 133 FC # Fibre Channel + diff --git a/base-files/files/etc/rc.button/failsafe b/base-files/files/etc/rc.button/failsafe new file mode 100755 index 000000000..ba958fa88 --- /dev/null +++ b/base-files/files/etc/rc.button/failsafe @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "${TYPE}" = "switch" ] || echo ${BUTTON} > /tmp/failsafe_button + +return 0 diff --git a/base-files/files/etc/rc.button/power b/base-files/files/etc/rc.button/power new file mode 100755 index 000000000..c24574417 --- /dev/null +++ b/base-files/files/etc/rc.button/power @@ -0,0 +1,7 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +exec /sbin/poweroff + +return 0 diff --git a/base-files/files/etc/rc.button/reboot b/base-files/files/etc/rc.button/reboot new file mode 100755 index 000000000..cd547e332 --- /dev/null +++ b/base-files/files/etc/rc.button/reboot @@ -0,0 +1,12 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +if [ "$SEEN" -ge 5 ] +then + echo "REBOOT" > /dev/console + sync + reboot +fi + +return 0 diff --git a/base-files/files/etc/rc.button/reset b/base-files/files/etc/rc.button/reset new file mode 100755 index 000000000..2403122ad --- /dev/null +++ b/base-files/files/etc/rc.button/reset @@ -0,0 +1,31 @@ +#!/bin/sh + +. /lib/functions.sh + +OVERLAY="$( grep ' /overlay ' /proc/mounts )" + +case "$ACTION" in +pressed) + [ -z "$OVERLAY" ] && return 0 + + return 5 +;; +timeout) + . /etc/diag.sh + set_state failsafe +;; +released) + if [ "$SEEN" -lt 1 ] + then + echo "REBOOT" > /dev/console + sync + reboot + elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ] + then + echo "FACTORY RESET" > /dev/console + jffs2reset -y && reboot & + fi +;; +esac + +return 0 diff --git a/base-files/files/etc/rc.button/rfkill b/base-files/files/etc/rc.button/rfkill new file mode 100755 index 000000000..fbdda40ed --- /dev/null +++ b/base-files/files/etc/rc.button/rfkill @@ -0,0 +1,32 @@ +#!/bin/sh + +[ "${ACTION}" = "released" -o -n "${TYPE}" ] || exit 0 + +. /lib/functions.sh + +rfkill_state=0 + +wifi_rfkill_set() { + uci set wireless.$1.disabled=$rfkill_state +} + +wifi_rfkill_check() { + local disabled + config_get disabled $1 disabled + [ "$disabled" = "1" ] || rfkill_state=1 +} + +config_load wireless +case "${TYPE}" in +"switch") + [ "${ACTION}" = "released" ] && rfkill_state=1 + ;; +*) + config_foreach wifi_rfkill_check wifi-device + ;; +esac +config_foreach wifi_rfkill_set wifi-device +uci commit wireless +wifi up + +return 0 diff --git a/base-files/files/etc/rc.common b/base-files/files/etc/rc.common new file mode 100755 index 000000000..d74730384 --- /dev/null +++ b/base-files/files/etc/rc.common @@ -0,0 +1,194 @@ +#!/bin/sh +# Copyright (C) 2006-2012 OpenWrt.org + +. $IPKG_INSTROOT/lib/functions.sh +. $IPKG_INSTROOT/lib/functions/service.sh + +initscript=$1 +action=${2:-help} +shift 2 + +start() { + return 0 +} + +stop() { + return 0 +} + +reload() { + restart +} + +restart() { + trap '' TERM + stop "$@" + trap - TERM + start "$@" +} + +boot() { + start "$@" +} + +shutdown() { + stop +} + +disable() { + name="$(basename "${initscript}")" + rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name + rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name +} + +enable() { + err=1 + name="$(basename "${initscript}")" + [ "$START" ] && \ + ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" && \ + err=0 + [ "$STOP" ] && \ + ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" && \ + err=0 + return $err +} + +enabled() { + name="$(basename "${initscript}")" + name="${name##[SK][0-9][0-9]}" + { + [ -z "${START:-}" ] || [ -L "$IPKG_INSTROOT/etc/rc.d/S${START}$name" ] + } && { + [ -z "${STOP:-}" ] || [ -L "$IPKG_INSTROOT/etc/rc.d/K${STOP}$name" ] + } +} + +depends() { + return 0 +} + +ALL_HELP="" +ALL_COMMANDS="boot shutdown depends" +extra_command() { + local cmd="$1" + local help="$2" + + local extra="$(printf "%-16s%s" "${cmd}" "${help}")" + ALL_HELP="${ALL_HELP}\t${extra}\n" + ALL_COMMANDS="${ALL_COMMANDS} ${cmd}" +} + +help() { + cat </dev/null >/dev/null; then + service_started + fi + } + + trace() { + TRACE_SYSCALLS=1 + start "$@" + } + + info() { + json_init + json_add_string name "$(basename ${basescript:-$initscript})" + json_add_boolean verbose "1" + _procd_ubus_call list + } + + stop() { + procd_lock + stop_service "$@" + procd_kill "$(basename ${basescript:-$initscript})" "$1" + if eval "type service_stopped" 2>/dev/null >/dev/null; then + service_stopped + fi + } + + reload() { + if eval "type reload_service" 2>/dev/null >/dev/null; then + procd_lock + reload_service "$@" + else + start + fi + } + + running() { + service_running "$@" + } + + status() { + if eval "type status_service" 2>/dev/null >/dev/null; then + status_service "$@" + else + _procd_status "$(basename ${basescript:-$initscript})" "$1" + fi + } +} + +ALL_COMMANDS="${ALL_COMMANDS} ${EXTRA_COMMANDS}" +ALL_HELP="${ALL_HELP}${EXTRA_HELP}" +list_contains ALL_COMMANDS "$action" || action=help +$action "$@" diff --git a/base-files/files/etc/rc.local b/base-files/files/etc/rc.local new file mode 100644 index 000000000..56394773c --- /dev/null +++ b/base-files/files/etc/rc.local @@ -0,0 +1,4 @@ +# Put your custom commands here that should be executed once +# the system init finished. By default this file does nothing. + +exit 0 diff --git a/base-files/files/etc/services b/base-files/files/etc/services new file mode 100644 index 000000000..968f9e78b --- /dev/null +++ b/base-files/files/etc/services @@ -0,0 +1,173 @@ +echo 7/tcp +echo 7/udp +discard 9/tcp +discard 9/udp +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +chargen 19/tcp +chargen 19/udp +ftp-data 20/tcp +ftp 21/tcp +ssh 22/tcp +ssh 22/udp +telnet 23/tcp +smtp 25/tcp +time 37/tcp +time 37/udp +whois 43/tcp +domain 53/tcp +domain 53/udp +bootps 67/tcp +bootps 67/udp +bootpc 68/tcp +bootpc 68/udp +tftp 69/udp +finger 79/tcp +www 80/tcp http +kerberos 88/tcp kerberos5 krb5 kerberos-sec +kerberos 88/udp kerberos5 krb5 kerberos-sec +pop3 110/tcp +pop3 110/udp +sunrpc 111/tcp rpcbind +sunrpc 111/udp rpcbind +auth 113/tcp ident +sftp 115/tcp +nntp 119/tcp +ntp 123/tcp +ntp 123/udp +netbios-ns 137/tcp +netbios-ns 137/udp +netbios-dgm 138/tcp +netbios-dgm 138/udp +netbios-ssn 139/tcp +netbios-ssn 139/udp +imap2 143/tcp imap +imap2 143/udp imap +snmp 161/tcp +snmp 161/udp +snmp-trap 162/tcp snmptrap +snmp-trap 162/udp snmptrap +xdmcp 177/tcp +xdmcp 177/udp +bgp 179/tcp +bgp 179/udp +imap3 220/tcp +imap3 220/udp +ldap 389/tcp +ldap 389/udp +https 443/tcp +https 443/udp +microsoft-ds 445/tcp +microsoft-ds 445/udp +isakmp 500/tcp +isakmp 500/udp +rtsp 554/tcp +rtsp 554/udp +ipp 631/tcp +ipp 631/udp +syslog 514/udp +printer 515/tcp spooler +dhcpv6-client 546/tcp +dhcpv6-client 546/udp +dhcpv6-server 547/tcp +dhcpv6-server 547/udp +afpovertcp 548/tcp +afpovertcp 548/udp +nntps 563/tcp snntp +nntps 563/udp snntp +submission 587/tcp +submission 587/udp +ldaps 636/tcp +ldaps 636/udp +tinc 655/tcp +tinc 655/udp +rsync 873/tcp +rsync 873/udp +ftps-data 989/tcp +ftps 990/tcp +imaps 993/tcp +imaps 993/udp +ircs 994/tcp +ircs 994/udp +pop3s 995/tcp +pop3s 995/udp +socks 1080/tcp +socks 1080/udp +openvpn 1194/tcp +openvpn 1194/udp +l2f 1701/tcp l2tp +l2f 1701/udp l2tp +radius 1812/tcp +radius 1812/udp +radius-acct 1813/tcp radacct +radius-acct 1813/udp radacct +nfs 2049/tcp +nfs 2049/udp +dict 2628/tcp +dict 2628/udp +gpsd 2947/tcp +gpsd 2947/udp +icpv2 3130/tcp icp +icpv2 3130/udp icp +mysql 3306/tcp +mysql 3306/udp +nut 3493/tcp +nut 3493/udp +distcc 3632/tcp +distcc 3632/udp +daap 3689/tcp +daap 3689/udp +svn 3690/tcp subversion +svn 3690/udp subversion +epmd 4369/tcp +epmd 4369/udp +iax 4569/tcp +iax 4569/udp +mtn 4691/tcp +mtn 4691/udp +munin 4949/tcp +sip 5060/tcp +sip 5060/udp +sip-tls 5061/tcp +sip-tls 5061/udp +xmpp-client 5222/tcp jabber-client +xmpp-client 5222/udp jabber-client +xmpp-server 5269/tcp jabber-server +xmpp-server 5269/udp jabber-server +mdns 5353/tcp +mdns 5353/udp +postgresql 5432/tcp postgres +postgresql 5432/udp postgres +x11 6000/tcp +x11 6000/udp +mysql-proxy 6446/tcp +mysql-proxy 6446/udp +bacula-dir 9101/tcp +bacula-dir 9101/udp +bacula-fd 9102/tcp +bacula-fd 9102/udp +bacula-sd 9103/tcp +bacula-sd 9103/udp +nbd 10809/tcp +zabbix-agent 10050/tcp +zabbix-agent 10050/udp +zabbix-trapper 10051/tcp +zabbix-trapper 10051/udp +hkp 11371/tcp +hkp 11371/udp +ssmtp 465/tcp smtps +spamd 783/tcp +zebrasrv 2600/tcp +zebra 2601/tcp +ripd 2602/tcp +ripngd 2603/tcp +ospfd 2604/tcp +bgpd 2605/tcp +ospf6d 2606/tcp +ospfapi 2607/tcp +isisd 2608/tcp +sane-port 6566/tcp sane saned +ircd 6667/tcp +git 9418/tcp + diff --git a/base-files/files/etc/shadow b/base-files/files/etc/shadow new file mode 100644 index 000000000..39bdb9c90 --- /dev/null +++ b/base-files/files/etc/shadow @@ -0,0 +1,5 @@ +root:::0:99999:7::: +daemon:*:0:0:99999:7::: +ftp:*:0:0:99999:7::: +network:*:0:0:99999:7::: +nobody:*:0:0:99999:7::: diff --git a/base-files/files/etc/shells b/base-files/files/etc/shells new file mode 100644 index 000000000..006aa38ce --- /dev/null +++ b/base-files/files/etc/shells @@ -0,0 +1 @@ +/bin/ash diff --git a/base-files/files/etc/shinit b/base-files/files/etc/shinit new file mode 100644 index 000000000..8df9771e6 --- /dev/null +++ b/base-files/files/etc/shinit @@ -0,0 +1,12 @@ +[ -x /bin/more ] || [ -x /usr/bin/more ] || alias more=less +[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi + +alias ll='ls -alF --color=auto' + +[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc + +[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; } +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } + +[ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit" +[ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc" diff --git a/base-files/files/etc/sysctl.conf b/base-files/files/etc/sysctl.conf new file mode 100644 index 000000000..ae04212f4 --- /dev/null +++ b/base-files/files/etc/sysctl.conf @@ -0,0 +1 @@ +# Defaults are configured in /etc/sysctl.d/* and can be customized in this file diff --git a/base-files/files/etc/sysctl.d/10-default.conf b/base-files/files/etc/sysctl.d/10-default.conf new file mode 100644 index 000000000..ee7df2bfa --- /dev/null +++ b/base-files/files/etc/sysctl.d/10-default.conf @@ -0,0 +1,28 @@ +# Do not edit, changes to this file will be lost on upgrades +# /etc/sysctl.conf can be used to customize sysctl settings + +kernel.panic=3 +kernel.core_pattern=/tmp/%e.%t.%p.%s.core +fs.suid_dumpable=2 + +fs.protected_hardlinks=1 +fs.protected_symlinks=1 + +net.core.bpf_jit_enable=1 +net.core.bpf_jit_kallsyms=1 + +net.ipv4.conf.default.arp_ignore=1 +net.ipv4.conf.all.arp_ignore=1 +net.ipv4.ip_forward=1 +net.ipv4.icmp_echo_ignore_broadcasts=1 +net.ipv4.icmp_ignore_bogus_error_responses=1 +net.ipv4.igmp_max_memberships=100 +net.ipv4.tcp_fin_timeout=30 +net.ipv4.tcp_keepalive_time=120 +net.ipv4.tcp_syncookies=1 +net.ipv4.tcp_timestamps=1 +net.ipv4.tcp_sack=1 +net.ipv4.tcp_dsack=1 + +net.ipv6.conf.default.forwarding=1 +net.ipv6.conf.all.forwarding=1 diff --git a/base-files/files/etc/sysupgrade.conf b/base-files/files/etc/sysupgrade.conf new file mode 100644 index 000000000..e06fd5e33 --- /dev/null +++ b/base-files/files/etc/sysupgrade.conf @@ -0,0 +1,5 @@ +## This file contains files and directories that should +## be preserved during an upgrade. + +# /etc/example.conf +# /etc/openvpn/ diff --git a/base-files/files/etc/uci-defaults/10_migrate-shadow b/base-files/files/etc/uci-defaults/10_migrate-shadow new file mode 100644 index 000000000..481444f35 --- /dev/null +++ b/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -0,0 +1,10 @@ +ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" +spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" + +if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then + logger -t migrate-shadow "Moving root password hash into shadow database" + sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd + sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow +fi + +exit 0 diff --git a/base-files/files/etc/uci-defaults/12_network-generate-ula b/base-files/files/etc/uci-defaults/12_network-generate-ula new file mode 100644 index 000000000..19d7ed7f2 --- /dev/null +++ b/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -0,0 +1,13 @@ +[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0 + +r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') +r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') +r3=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') + +uci -q batch <<-EOF >/dev/null + set network.globals.ula_prefix=fd$r1:$r2:$r3::/48 + commit network +EOF + +exit 0 + diff --git a/base-files/files/etc/uci-defaults/13_fix-group-user b/base-files/files/etc/uci-defaults/13_fix-group-user new file mode 100644 index 000000000..74f501e8f --- /dev/null +++ b/base-files/files/etc/uci-defaults/13_fix-group-user @@ -0,0 +1,9 @@ +. /lib/functions.sh + +for file in $(grep -sl Require-User /usr/lib/opkg/info/*.control); do + file="${file##*/}" + file="${file%.control}" + add_group_and_user "${file}" +done + +exit 0 diff --git a/base-files/files/lib/functions.sh b/base-files/files/lib/functions.sh new file mode 100644 index 000000000..4b1b83857 --- /dev/null +++ b/base-files/files/lib/functions.sh @@ -0,0 +1,436 @@ +# Copyright (C) 2006-2014 OpenWrt.org +# Copyright (C) 2006 Fokus Fraunhofer +# Copyright (C) 2010 Vertical Communications + + +debug () { + ${DEBUG:-:} "$@" +} + +# newline +N=" +" + +_C=0 +NO_EXPORT=1 +LOAD_STATE=1 +LIST_SEP=" " + +# xor multiple hex values of the same length +xor() { + local val + local ret="0x$1" + local retlen=${#1} + + shift + while [ -n "$1" ]; do + val="0x$1" + ret=$((ret ^ val)) + shift + done + + printf "%0${retlen}x" "$ret" +} + +append() { + local var="$1" + local value="$2" + local sep="${3:- }" + + eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\"" +} + +list_contains() { + local var="$1" + local str="$2" + local val + + eval "val=\" \${$var} \"" + [ "${val%% $str *}" != "$val" ] +} + +config_load() { + [ -n "$IPKG_INSTROOT" ] && return 0 + uci_load "$@" +} + +reset_cb() { + config_cb() { return 0; } + option_cb() { return 0; } + list_cb() { return 0; } +} +reset_cb + +package() { + return 0 +} + +config () { + local cfgtype="$1" + local name="$2" + + export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$((CONFIG_NUM_SECTIONS + 1)) + name="${name:-cfg$CONFIG_NUM_SECTIONS}" + append CONFIG_SECTIONS "$name" + export ${NO_EXPORT:+-n} CONFIG_SECTION="$name" + config_set "$CONFIG_SECTION" "TYPE" "${cfgtype}" + [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name" +} + +option () { + local varname="$1"; shift + local value="$*" + + config_set "$CONFIG_SECTION" "${varname}" "${value}" + [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*" +} + +list() { + local varname="$1"; shift + local value="$*" + local len + + config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0 + [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}" + len=$((len + 1)) + config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value" + config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len" + append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP" + [ -n "$NO_CALLBACK" ] || list_cb "$varname" "$*" +} + +config_unset() { + config_set "$1" "$2" "" +} + +# config_get