diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 8a1ddf96f5..20cb8df442 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_FLAGS:=nonshared +PKG_FLAGS:=hold essential nonshared PKG_RELEASE:=$(COMMITCOUNT) PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ @@ -37,7 +37,8 @@ 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 + DEPENDS:=+netifd +libc +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:openwrt-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool \ + blkid mount-utils e2fsprogs tune2fs resize2fs TITLE:=Base filesystem for OpenWrt URL:=http://openwrt.org/ VERSION:=$(PKG_RELEASE)-$(REVISION) @@ -181,6 +182,9 @@ define Package/base-files/install chmod 0600 $(1)/etc/shadow chmod 1777 $(1)/tmp + $(LN) /tmp/run $(1)/run + mkdir -p $(1)/ext_overlay + $(call ImageConfigOptions,$(1)) $(call Package/base-files/install-target,$(1)) for conffile in $(1)/etc/config/*; do \ diff --git a/package/base-files/files/lib/functions/istoreos-boot.sh b/package/base-files/files/lib/functions/istoreos-boot.sh new file mode 100644 index 0000000000..85393b7d6d --- /dev/null +++ b/package/base-files/files/lib/functions/istoreos-boot.sh @@ -0,0 +1,17 @@ + +. /lib/upgrade/common.sh + +get_overlay_partition() +{ + local overlay_dev + export_bootdevice && export_partdevice overlay_dev 3 || { + log "Unable to determine overlay partition" + return 1 + } + if [ -z "$overlay_dev" ]; then + log "Unable to determine overlay partition" + return 1 + fi + OVERLAY_DEV="/dev/$overlay_dev" + +} diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index f2d1c46152..12d2b61c6d 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -106,6 +106,19 @@ kill_remaining() { # [ [ ] ] _v } +istoreos_pre_upgrade() { + if [ -n "$UPGRADE_BACKUP" ]; then + # reset rom uuid in ext_overlay + if [ -e /ext_overlay/etc ]; then + rm -f /ext_overlay/etc/.extroot-uuid + rm -f /ext_overlay/upper/usr/lib/opkg/.upgrading + sync /ext_overlay + fi + rm -f /overlay/upper/usr/lib/opkg/.upgrading + touch /overlay/upper/usr/lib/opkg/.upgrading && sync /overlay + fi +} + indicate_upgrade killall -9 telnetd @@ -123,6 +136,8 @@ sleep 1 echo 3 > /proc/sys/vm/drop_caches +[ -n "$IMAGE" ] && istoreos_pre_upgrade + if [ -n "$IMAGE" ] && type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then platform_pre_upgrade "$IMAGE" fi diff --git a/package/base-files/files/sbin/firstboot b/package/base-files/files/sbin/firstboot index d9af57d596..b9898e2d2e 100755 --- a/package/base-files/files/sbin/firstboot +++ b/package/base-files/files/sbin/firstboot @@ -1,3 +1,86 @@ #!/bin/sh +# Copyright (C) 2022 jjm2473@gmail.com -/sbin/jffs2reset $@ +DEFAULT_OVERLAY_FS="ext4" +OVERLAY_LABEL="etc" + +OVERLAY_FS=${DEFAULT_OVERLAY_FS} +OVERLAY_DEV= + +log() { + echo "$1" >&2 +} + +inlog() { + $@ >&2 +} + +. /lib/functions/istoreos-boot.sh + +CONFIRM=n +REBOOT=n + +confirm() +{ + [ "$1" = "y" ] && return 0 + echo "This will erase all settings and remove any installed packages. Are you sure? [N/y]" + read CONFIRM + [ "$CONFIRM" = "y" -o "$CONFIRM" = "Y" ] && return 0 + return 1 +} + +do_reset_nofs() +{ + get_overlay_partition || return 1 + + if [ -z "$OVERLAY_DEV" ]; then + echo "Unable to determine overlay partition" >&2 + return 1 + fi + if [ "RESET" = "$FSTYPE" ]; then + echo "Already resetted" >&2 + return 1 + fi + if ! blkid -o device -t LABEL=$OVERLAY_LABEL "$OVERLAY_DEV" >/dev/null; then + echo "Overlay partition $OVERLAY_DEV not labeled $OVERLAY_LABEL" >&2 + return 1 + fi + + echo "RESET000" | dd of="$OVERLAY_DEV" bs=512 count=1 conv=notrunc,sync,fsync 2>/dev/null + echo 3 > /proc/sys/vm/drop_caches + return 0 +} + +do_reset_ext_overlay() +{ + rm -f /ext_overlay/etc/.extroot-uuid + touch /ext_overlay/.reset + sync /ext_overlay +} + +do_reset() +{ + if [ -f /.recovery_mode ]; then + mount_root || ( echo "/overlay mount failed!" ; exit 1 ) + rm -rf /overlay/upper + mkdir /overlay/upper + sync /overlay + else + do_reset_nofs + do_reset_ext_overlay + fi + [ "$REBOOT" = "y" ] && reboot + exit 0 +} + +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -y) CONFIRM=y ;; + -r) REBOOT=y ;; + esac + shift +done + +confirm $CONFIRM && do_reset +exit 0 diff --git a/target/linux/realtek/base-files/usr/sbin/mount_root b/package/base-files/files/usr/sbin/mount_root similarity index 66% rename from target/linux/realtek/base-files/usr/sbin/mount_root rename to package/base-files/files/usr/sbin/mount_root index 340cd94caa..3bc41274b9 100755 --- a/target/linux/realtek/base-files/usr/sbin/mount_root +++ b/package/base-files/files/usr/sbin/mount_root @@ -5,50 +5,47 @@ DEFAULT_OVERLAY_FS="ext4" OVERLAY_LABEL="etc" -get_overlay_partition_from_kernel_cmdline() +OVERLAY_FS=${DEFAULT_OVERLAY_FS} +OVERLAY_DEV= + +log() { + echo "<1>mount_root: $1" >/dev/kmsg +} + +inlog() { + $@ >/dev/kmsg 2>&1 +} + +. /lib/functions/istoreos-boot.sh + +validate_overlay_partition() { - OVERLAY_FS=${DEFAULT_OVERLAY_FS} - - for item in `cat /proc/cmdline`; do - case $item in - overlay=*) OVERLAY_DEV=${item:8};; - overlayfs=*) OVERLAY_FS=${item:10};; - esac - done - - if [ -z "$OVERLAY_DEV" ]; then - OVERLAY_DEV=`blkid -L $OVERLAY_LABEL | grep /mmcblk0p` - [ -z "$OVERLAY_DEV" ] || echo "overlay dev not define by cmdline, fine $OVERLAY_LABEL got $OVERLAY_DEV" - fi - - if [ -z "$OVERLAY_DEV" ]; then - if dd if=/dev/mmcblk0p2 bs=5 count=1 | grep -qF RESET; then - OVERLAY_DEV=/dev/mmcblk0p2 - FSTYPE=RESET - echo "overlay not found by cmdline or label, we got resetting $OVERLAY_DEV" - fi - fi - - [ -z "$OVERLAY_DEV" ] && return 1 - - echo "- mount overlayfs -" + log "- mount overlayfs -" # Check device existence - [ ! -e $OVERLAY_DEV ] && \ - echo "overlay: $OVERLAY_DEV not found" && return 1 + [ ! -e "$OVERLAY_DEV" ] && \ + log "overlay: $OVERLAY_DEV not found" && return 1 - # Check filesystem - if [ -z "$FSTYPE" ]; then - if dd if=$OVERLAY_DEV bs=5 count=1 | grep -qF RESET; then - FSTYPE=RESET - else - FSTYPE=`blkid -o value -s TYPE $OVERLAY_DEV` - fi + [ -n "$FSTYPE" ] && return 0 + + # get filesystem + if dd if="$OVERLAY_DEV" bs=5 count=1 2>/dev/null | grep -qF RESET; then + FSTYPE=RESET + log "overlay: $OVERLAY_DEV marked as RESET, format later" + return 0 + elif blkid -o device -t LABEL=$OVERLAY_LABEL "$OVERLAY_DEV" >/dev/null; then + FSTYPE=`blkid -o value -s TYPE $OVERLAY_DEV` + else + FSTYPE=RESET + log "overlay: $OVERLAY_DEV not labeled, format later" + return 0 fi - [ -z "$FSTYPE" ] && \ - echo "overlay: no valid filesystem" || \ - echo "overlay: filesystem $FSTYPE found" + if [ -z "$FSTYPE" ]; then + log "overlay: no valid filesystem" + else + log "overlay: filesystem $FSTYPE found" + fi } format_overlay_partition() @@ -56,22 +53,22 @@ format_overlay_partition() local RET [ "$FSTYPE" = "$OVERLAY_FS" ] && return 0 - echo "overlay: try to format $OVERLAY_DEV as $OVERLAY_FS partition" + log "overlay: try to format $OVERLAY_DEV as $OVERLAY_FS partition" case "$OVERLAY_FS" in ext4) - mkfs.ext4 -q -j -FF -L $OVERLAY_LABEL $OVERLAY_DEV + mkfs.ext4 -q -j -FF -L $OVERLAY_LABEL "$OVERLAY_DEV" RET=$? - [ $RET -ne 0 ] || tune2fs -o '^user_xattr,^acl' -r 1024 $OVERLAY_DEV + [ $RET -ne 0 ] || tune2fs -o '^user_xattr,^acl' -r 1024 "$OVERLAY_DEV" ;; *) - echo "overlay: unhandled fs type : $OVERLAY_FS" + log "overlay: unhandled fs type : $OVERLAY_FS" RET=1 ;; esac if [ $RET -ne 0 ]; then - echo "overlay: format command failed ret: $RET" + log "overlay: format command failed ret: $RET" else echo 3 > /proc/sys/vm/drop_caches FSTYPE=$OVERLAY_FS @@ -84,9 +81,9 @@ check_overlay_partition() { case "$FSTYPE" in ext4) - fsck.ext4 -y $OVERLAY_DEV + fsck.ext4 -y "$OVERLAY_DEV" sync - resize2fs $OVERLAY_DEV + resize2fs "$OVERLAY_DEV" sync ;; esac @@ -95,13 +92,13 @@ check_overlay_partition() mount_overlay_partition() { local RET - mount -t $OVERLAY_FS $OVERLAY_DEV /overlay + mount -t $OVERLAY_FS "$OVERLAY_DEV" /overlay RET=$? [ $RET -ne 0 ] && \ - echo "overlay: failed to mount $OVERLAY_DEV as $OVERLAY_FS partition ret: $RET" && return $RET + log "overlay: failed to mount $OVERLAY_DEV as $OVERLAY_FS partition ret: $RET" && return $RET - echo 'overlay: successfully mounted' + log 'overlay: successfully mounted' } prepare_primary_overlay() @@ -194,7 +191,7 @@ prepare_mnt() if mountpoint -q /tmp/extroot/overlay; then # use ext overlay as upper layer local newoverlaydir=/tmp/extroot/overlay - if [ `mountpoint -x $OVERLAY_DEV` != `mountpoint -d $newoverlaydir` ] && \ + if [ `mountpoint -x "$OVERLAY_DEV"` != `mountpoint -d $newoverlaydir` ] && \ prepare_ext_overlay $newoverlaydir $overlaydir && \ mount --move /tmp/extroot/overlay /ext_overlay; then lowerdir=$overlaydir/upper:$lowerdir @@ -224,29 +221,31 @@ do_mount_overlayfs() { [ ! -e /rom/note ] && return 0 - get_overlay_partition_from_kernel_cmdline || return 1 + inlog get_overlay_partition || return 1 - format_overlay_partition || return 1 + inlog validate_overlay_partition || return 1 - check_overlay_partition + inlog format_overlay_partition || return 1 - mount_overlay_partition || return 1 + inlog check_overlay_partition + + inlog mount_overlay_partition || return 1 # if we are in recovery mode, just skip pivot_root if [ -f /.recovery_mode ]; then - rm -f /rom/note + rm -f /rom/note >/dev/null 2>&1 return 0 fi - prepare_primary_overlay + inlog prepare_primary_overlay - prepare_mnt || return 1 + inlog prepare_mnt || return 1 - pivot_root_to_overlayfs || return 1 + inlog pivot_root_to_overlayfs || return 1 clean_extroot >/dev/null 2>&1 - mount --make-shared -t tmpfs -o size=4M tmpfs /mnt + inlog mount --make-shared -t tmpfs -o size=4M tmpfs /mnt return 0 } diff --git a/package/istoreos-files/Makefile b/package/istoreos-files/Makefile new file mode 100644 index 0000000000..a8cc0f16de --- /dev/null +++ b/package/istoreos-files/Makefile @@ -0,0 +1,75 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=istoreos-files +PKG_VERSION:=1 +PKG_RELEASE:=1 +PKG_FLAGS:=hold essential nonshared + +PKG_LICENSE:=CC0-1.0 +PKG_MAINTAINER:=jjm2473 + +include $(INCLUDE_DIR)/package.mk + +define Package/istoreos-files + SECTION:=base + CATEGORY:=Base system + TITLE:=iStoreOS files + MAINTAINER:=jjm2473 + DEFAULT:=y + HIDDEN:=y +endef + +define Package/istoreos-files/description + The iStoreOS. +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Compile/Default + +endef +Build/Compile = $(Build/Compile/Default) + +define Package/istoreos-files/install + $(CP) ./files/* $(1)/ +endef + + +define Package/istoreos-files/postinst +#!/bin/sh + +HOST_SED="$(subst ${STAGING_DIR_HOST},$${STAGING_DIR_HOST},$(SED))" +HOST_LN="$(subst ${STAGING_DIR_HOST},$${STAGING_DIR_HOST},$(LN))" + +[ -n "$${IPKG_INSTROOT}" ] && { + $${HOST_SED} '/^src\/gz openwrt_\(base\|luci\|packages\|routing\|telephony\) /!d' "$${IPKG_INSTROOT}/etc/opkg/distfeeds.conf" + + $${HOST_SED} 's/"192.168.1.1"/"192.168.100.1"/' \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/controller/admin/system.lua" \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/controller/admin/ota.lua" \ + "$${IPKG_INSTROOT}/etc/board.d/99-default_network" + + $${HOST_SED} "s/'192\\.168\\.1\\.1'/'192.168.100.1'/; s/'openwrt\\.lan'/window.location.host/" "$${IPKG_INSTROOT}/www/luci-static/resources/view/system/flash.js" + + $${HOST_SED} 's/s\.anonymous = true/s\.anonymous = true\ns\.addremove = true/' "$${IPKG_INSTROOT}/usr/lib/lua/luci/model/cbi/hd_idle.lua" + + $${HOST_SED} 's#"/opt"#"/overlay/upper/opt/docker"#' "$${IPKG_INSTROOT}/usr/lib/lua/luci/model/cbi/admin_system/fstab/mount.lua" + + $${HOST_LN} /usr/sbin/jffs2reset "$${IPKG_INSTROOT}/sbin/jffs2reset" + + $${HOST_SED} '//a ' \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon/header.htm" \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_dark/header.htm" \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_light/header.htm" \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_dark_purple/header.htm" \ + "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_light_green/header.htm" + + rm -f "$${IPKG_INSTROOT}/etc/uci-defaults/luci-argon-config" + + true +} +endef + +$(eval $(call BuildPackage,istoreos-files)) diff --git a/package/istoreos-files/files/etc/board.d/10_system b/package/istoreos-files/files/etc/board.d/10_system new file mode 100755 index 0000000000..336746daab --- /dev/null +++ b/package/istoreos-files/files/etc/board.d/10_system @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Copyright (C) 2018 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh + +board_config_update + +ucidef_set_hostname "iStoreOS" + +ucidef_set_ntpserver "0.cn.pool.ntp.org" "1.cn.pool.ntp.org" "2.cn.pool.ntp.org" "3.cn.pool.ntp.org" + +board_config_flush + +exit 0 \ No newline at end of file diff --git a/target/linux/realtek/base-files/etc/crontabs/root b/package/istoreos-files/files/etc/crontabs/root similarity index 100% rename from target/linux/realtek/base-files/etc/crontabs/root rename to package/istoreos-files/files/etc/crontabs/root diff --git a/target/linux/realtek/base-files/etc/init.d/debug b/package/istoreos-files/files/etc/init.d/debug similarity index 100% rename from target/linux/realtek/base-files/etc/init.d/debug rename to package/istoreos-files/files/etc/init.d/debug diff --git a/package/istoreos-files/files/etc/init.d/fix_luci_lang b/package/istoreos-files/files/etc/init.d/fix_luci_lang new file mode 100755 index 0000000000..d3a03c7b1b --- /dev/null +++ b/package/istoreos-files/files/etc/init.d/fix_luci_lang @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2016 OpenWrt.org + +START=49 + +list_langs() { + cd /usr/lib/lua/luci/i18n + ls | sed -e 's/.*\.\([^\.]*\)\.lmo/\1/g' | sort -u +} + +boot() { + local lang + local name + for lang in `list_langs` + do + if ! uci get luci.languages.${lang//-/_} >/dev/null 2>&1; then + name=`luci18n2name $lang` + uci set "luci.languages.${lang//-/_}=${name:-$lang}" + fi + done + uci changes luci | grep -Fqm1 luci 2>/dev/null && uci commit luci >/dev/null 2>&1 +} \ No newline at end of file diff --git a/target/linux/realtek/base-files/etc/init.d/rtk_stop b/package/istoreos-files/files/etc/init.d/isos_stop similarity index 100% rename from target/linux/realtek/base-files/etc/init.d/rtk_stop rename to package/istoreos-files/files/etc/init.d/isos_stop diff --git a/target/linux/realtek/base-files/etc/init.d/rtk_upgrade b/package/istoreos-files/files/etc/init.d/isos_upgrade similarity index 96% rename from target/linux/realtek/base-files/etc/init.d/rtk_upgrade rename to package/istoreos-files/files/etc/init.d/isos_upgrade index fb3b3ba567..511ca912a5 100755 --- a/target/linux/realtek/base-files/etc/init.d/rtk_upgrade +++ b/package/istoreos-files/files/etc/init.d/isos_upgrade @@ -1,5 +1,6 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2016 OpenWrt.org +# istoreos upgrade post process +# Copyright (C) 2022 jjm2473 START=14 diff --git a/target/linux/realtek/base-files/etc/init.d/wan_drop b/package/istoreos-files/files/etc/init.d/wan_drop similarity index 100% rename from target/linux/realtek/base-files/etc/init.d/wan_drop rename to package/istoreos-files/files/etc/init.d/wan_drop diff --git a/package/istoreos-files/files/etc/init.d/zprintk b/package/istoreos-files/files/etc/init.d/zprintk new file mode 100755 index 0000000000..71e0b7bcd9 --- /dev/null +++ b/package/istoreos-files/files/etc/init.d/zprintk @@ -0,0 +1,9 @@ +#!/bin/sh /etc/rc.common +# 2022 jjm2473 + +START=99 + +boot() { + # tune printk level after success boot, avoid noise in console + echo '4 5 1 7' > /proc/sys/kernel/printk +} diff --git a/target/linux/realtek/base-files/etc/sysctl.d/12-nf-conntrack-max.conf b/package/istoreos-files/files/etc/sysctl.d/12-nf-conntrack-max.conf similarity index 100% rename from target/linux/realtek/base-files/etc/sysctl.d/12-nf-conntrack-max.conf rename to package/istoreos-files/files/etc/sysctl.d/12-nf-conntrack-max.conf diff --git a/target/linux/realtek/base-files/etc/uci-defaults/09_realtek b/package/istoreos-files/files/etc/uci-defaults/09_istoreos similarity index 89% rename from target/linux/realtek/base-files/etc/uci-defaults/09_realtek rename to package/istoreos-files/files/etc/uci-defaults/09_istoreos index 6206ebf8f1..357b55b519 100644 --- a/target/linux/realtek/base-files/etc/uci-defaults/09_realtek +++ b/package/istoreos-files/files/etc/uci-defaults/09_istoreos @@ -1,12 +1,9 @@ #!/bin/sh +# Copyright (C) 2022 jjm2473 uci -q batch <<-EOF >/dev/null set system.@system[-1].zonename='Asia/Shanghai' set system.@system[-1].timezone='CST-8' - add_list system.ntp.server='0.cn.pool.ntp.org' - add_list system.ntp.server='1.cn.pool.ntp.org' - add_list system.ntp.server='2.cn.pool.ntp.org' - add_list system.ntp.server='3.cn.pool.ntp.org' commit system EOF diff --git a/target/linux/realtek/base-files/etc/uci-defaults/41_upnp_force b/package/istoreos-files/files/etc/uci-defaults/41_upnp_force similarity index 100% rename from target/linux/realtek/base-files/etc/uci-defaults/41_upnp_force rename to package/istoreos-files/files/etc/uci-defaults/41_upnp_force diff --git a/target/linux/realtek/base-files/etc/uci-defaults/99_theme b/package/istoreos-files/files/etc/uci-defaults/99_theme similarity index 100% rename from target/linux/realtek/base-files/etc/uci-defaults/99_theme rename to package/istoreos-files/files/etc/uci-defaults/99_theme diff --git a/package/istoreos-files/files/usr/bin/luci18n2name b/package/istoreos-files/files/usr/bin/luci18n2name new file mode 100755 index 0000000000..3edf84addc --- /dev/null +++ b/package/istoreos-files/files/usr/bin/luci18n2name @@ -0,0 +1,45 @@ +#!/bin/sh +# author: jjm2473 + +toname() { + local lang_ar="العربية (Arabic)" + local lang_bg="български (Bulgarian)" + local lang_bn="বাংলা (Bengali)" + local lang_ca="Català (Catalan)" + local lang_cs="Čeština (Czech)" + local lang_da="Dansk (Danish)" + local lang_de="Deutsch (German)" + local lang_el="Ελληνικά (Greek)" + local lang_en="English" + local lang_es="Español (Spanish)" + local lang_fi="Suomi (Finnish)" + local lang_fr="Français (French)" + local lang_he="עִבְרִית (Hebrew)" + local lang_hi="हिंदी (Hindi)" + local lang_hu="Magyar (Hungarian)" + local lang_it="Italiano (Italian)" + local lang_ja="日本語 (Japanese)" + local lang_ko="한국어 (Korean)" + local lang_mr="Marāṭhī (Marathi)" + local lang_ms="Bahasa Melayu (Malay)" + local lang_no="Norsk (Norwegian)" + local lang_nl="Nederlands (Dutch)" + local lang_pl="Polski (Polish)" + local lang_pt_br="Português do Brasil (Brazilian Portuguese)" + local lang_pt="Português (Portuguese)" + local lang_ro="Română (Romanian)" + local lang_ru="Русский (Russian)" + local lang_sk="Slovenčina (Slovak)" + local lang_sv="Svenska (Swedish)" + local lang_tr="Türkçe (Turkish)" + local lang_uk="Українська (Ukrainian)" + local lang_vi="Tiếng Việt (Vietnamese)" + local lang_zh_cn="简体中文 (Chinese Simplified)" + local lang_zh_tw="繁體中文 (Chinese Traditional)" + + eval "[ -n \"\${lang_$1}\" ] && echo \${lang_$1}" +} + +if [ -n "$1" ]; then + toname ${1//-/_} +fi \ No newline at end of file diff --git a/package/istoreos-files/files/usr/lib/lua/luci/controller/admin/compat.lua b/package/istoreos-files/files/usr/lib/lua/luci/controller/admin/compat.lua new file mode 100644 index 0000000000..bad1b46e61 --- /dev/null +++ b/package/istoreos-files/files/usr/lib/lua/luci/controller/admin/compat.lua @@ -0,0 +1,10 @@ +-- Copyright 2022 jjm2473 +-- Licensed to the public under the Apache License 2.0. + +module("luci.controller.admin.compat", package.seeall) + +function action_fatab() + local dsp = require "luci.dispatcher" + + luci.http.redirect(dsp.build_url("admin/system/mounts")) +end diff --git a/package/istoreos-files/files/usr/share/luci/menu.d/luci-mod-system-fstab.json b/package/istoreos-files/files/usr/share/luci/menu.d/luci-mod-system-fstab.json new file mode 100644 index 0000000000..88d8977c97 --- /dev/null +++ b/package/istoreos-files/files/usr/share/luci/menu.d/luci-mod-system-fstab.json @@ -0,0 +1,9 @@ +{ + "admin/system/fstab": { + "action": { + "type": "call", + "module": "luci.controller.admin.compat", + "function": "action_fatab" + } + } +} diff --git a/target/linux/realtek/base-files/www/luci-static/resources/easepi/easeicon.css b/package/istoreos-files/files/www/luci-static/resources/easepi/easeicon.css similarity index 100% rename from target/linux/realtek/base-files/www/luci-static/resources/easepi/easeicon.css rename to package/istoreos-files/files/www/luci-static/resources/easepi/easeicon.css diff --git a/target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.ttf b/package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.ttf similarity index 100% rename from target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.ttf rename to package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.ttf diff --git a/target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.woff b/package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.woff similarity index 100% rename from target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.woff rename to package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.woff diff --git a/target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.woff2 b/package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.woff2 similarity index 100% rename from target/linux/realtek/base-files/www/luci-static/resources/easepi/iconfont.woff2 rename to package/istoreos-files/files/www/luci-static/resources/easepi/iconfont.woff2 diff --git a/target/linux/realtek/base-files.mk b/target/linux/realtek/base-files.mk index 9fa31844e2..ef06f2920d 100644 --- a/target/linux/realtek/base-files.mk +++ b/target/linux/realtek/base-files.mk @@ -1,41 +1,4 @@ define Package/base-files/install-target chmod 0400 $(1)/etc/public.key - $(LN) /tmp/run $(1)/run - $(INSTALL_DIR) $(1)/ext_overlay -endef - -define Package/base-files/postinst -#!/bin/sh - -HOST_SED="$(subst ${STAGING_DIR_HOST},$${STAGING_DIR_HOST},$(SED))" -HOST_LN="$(subst ${STAGING_DIR_HOST},$${STAGING_DIR_HOST},$(LN))" - -[ -n "$${IPKG_INSTROOT}" ] && { - $${HOST_SED} '/^src\/gz openwrt_\(base\|luci\|packages\|routing\|telephony\) /!d' "$${IPKG_INSTROOT}/etc/opkg/distfeeds.conf" - - $${HOST_SED} 's/"192.168.1.1"/"192.168.100.1"/' \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/controller/admin/system.lua" \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/controller/admin/ota.lua" \ - "$${IPKG_INSTROOT}/etc/board.d/99-default_network" - - $${HOST_SED} "s/'192\\.168\\.1\\.1'/'192.168.100.1'/; s/'openwrt\\.lan'/window.location.host/" "$${IPKG_INSTROOT}/www/luci-static/resources/view/system/flash.js" - - $${HOST_SED} 's/s\.anonymous = true/s\.anonymous = true\ns\.addremove = true/' "$${IPKG_INSTROOT}/usr/lib/lua/luci/model/cbi/hd_idle.lua" - - $${HOST_SED} 's#"/opt"#"/overlay/upper/opt/docker"#' "$${IPKG_INSTROOT}/usr/lib/lua/luci/model/cbi/admin_system/fstab/mount.lua" - - $${HOST_LN} /usr/sbin/jffs2reset "$${IPKG_INSTROOT}/sbin/jffs2reset" - - $${HOST_SED} '//a ' \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon/header.htm" \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_dark/header.htm" \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_light/header.htm" \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_dark_purple/header.htm" \ - "$${IPKG_INSTROOT}/usr/lib/lua/luci/view/themes/argon_light_green/header.htm" - - rm -f "$${IPKG_INSTROOT}/etc/uci-defaults/luci-argon-config" - - true -} endef diff --git a/target/linux/realtek/base-files/etc/board.d/10_system b/target/linux/realtek/base-files/etc/board.d/11_system similarity index 100% rename from target/linux/realtek/base-files/etc/board.d/10_system rename to target/linux/realtek/base-files/etc/board.d/11_system diff --git a/target/linux/realtek/base-files/lib/functions/istoreos-boot.sh b/target/linux/realtek/base-files/lib/functions/istoreos-boot.sh new file mode 100644 index 0000000000..35032d009f --- /dev/null +++ b/target/linux/realtek/base-files/lib/functions/istoreos-boot.sh @@ -0,0 +1,31 @@ + +get_overlay_partition() +{ + + for item in `cat /proc/cmdline`; do + case $item in + overlay=*) OVERLAY_DEV=${item:8};; + overlayfs=*) OVERLAY_FS=${item:10};; + esac + done + + if [ -z "$OVERLAY_DEV" ]; then + OVERLAY_DEV=`blkid -L $OVERLAY_LABEL | grep /mmcblk0p` + [ -z "$OVERLAY_DEV" ] || log "overlay dev not define by cmdline, fine $OVERLAY_LABEL got $OVERLAY_DEV" + fi + + if [ -z "$OVERLAY_DEV" ]; then + if dd if=/dev/mmcblk0p2 bs=5 count=1 2>/dev/null | grep -qF RESET; then + OVERLAY_DEV=/dev/mmcblk0p2 + FSTYPE=RESET + log "overlay not found by cmdline or label, but we found $OVERLAY_DEV marked as RESET, format later" + fi + fi + + if [ -z "$OVERLAY_DEV" ]; then + log "Unable to determine overlay partition" + return 1 + fi + + return 0 +} diff --git a/target/linux/realtek/base-files/lib/upgrade/platform.sh b/target/linux/realtek/base-files/lib/upgrade/platform.sh index b82c6db710..8ee7ca2d95 100755 --- a/target/linux/realtek/base-files/lib/upgrade/platform.sh +++ b/target/linux/realtek/base-files/lib/upgrade/platform.sh @@ -12,18 +12,6 @@ platform_check_image() { return 0 } -platform_pre_upgrade() { - if [ -n "$UPGRADE_BACKUP" ]; then - if [ -e /ext_overlay/etc ]; then - rm -f /ext_overlay/etc/.extroot-uuid - rm -f /ext_overlay/upper/usr/lib/opkg/.upgrading - sync /ext_overlay - fi - rm -f /overlay/upper/usr/lib/opkg/.upgrading - touch /overlay/upper/usr/lib/opkg/.upgrading && sync /overlay - fi -} - platform_do_upgrade() { grep /ext_overlay /proc/mounts > /dev/null && { /bin/mount -o noatime,remount,ro /ext_overlay diff --git a/target/linux/realtek/base-files/usr/sbin/jffs2reset b/target/linux/realtek/base-files/usr/sbin/jffs2reset deleted file mode 100755 index 1ffa3fc6d8..0000000000 --- a/target/linux/realtek/base-files/usr/sbin/jffs2reset +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -OVERLAY_LABEL="etc" -CONFIRM=n -REBOOT=n - -confirm() -{ - [ "$1" = "y" ] && return 0 - echo "This will erase all settings and remove any installed packages. Are you sure? [N/y]" - read CONFIRM - [ "$CONFIRM" = "y" -o "$CONFIRM" = "Y" ] && return 0 - return 1 -} - -do_reset_nofs() -{ - local OVERLAY_DEV= - for item in `cat /proc/cmdline`; do - case $item in - overlay=*) OVERLAY_DEV=${item:8};; - esac - done - if [ -z "$OVERLAY_DEV" ]; then - OVERLAY_DEV=`blkid -L $OVERLAY_LABEL | grep /mmcblk0p` - fi - if [ -z "$OVERLAY_DEV" ]; then - echo "overlay not found by cmdline or label, maybe we are already in resetting?" >&2 - return 0 - fi - - echo "RESET000" | dd of=$OVERLAY_DEV bs=512 count=1 conv=notrunc - echo 3 > /proc/sys/vm/drop_caches - return 0 -} - -do_reset() -{ - if [ -f /.recovery_mode ]; then - mount_root || ( echo "/overlay mount failed!" ; exit 1 ) - rm -rf /overlay/upper - mkdir /overlay/upper - sync /overlay - else - if touch /overlay/.reset; then - sync /overlay - else - do_reset_nofs - fi - fi - [ "$REBOOT" = "y" ] && reboot - exit 0 -} - -while [[ $# -gt 0 ]]; do - key="$1" - case $key in - -y) CONFIRM=y ;; - -r) REBOOT=y ;; - esac - shift -done - -confirm $CONFIRM && do_reset -exit 0