Skip to content

Commit 2e92487

Browse files
committed
Add partition mount point check
1 parent d2df2ad commit 2e92487

File tree

7 files changed

+85
-10
lines changed

7 files changed

+85
-10
lines changed

luci-app-amlogic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
include $(TOPDIR)/rules.mk
1717

1818
PKG_NAME:=luci-app-amlogic
19-
PKG_VERSION:=3.1.269
19+
PKG_VERSION:=3.1.270
2020
PKG_RELEASE:=1
2121

2222
PKG_LICENSE:=GPL-2.0 License

luci-app-amlogic/root/usr/sbin/openwrt-backup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ EOF
258258
259259
EOF
260260
echo "/etc/config/fstab generated."
261-
echo "please reboot"
261+
echo "Please reboot before continuing."
262262
exit 0
263263
}
264264

luci-app-amlogic/root/usr/sbin/openwrt-kernel

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ error_msg() {
3737
exit 1
3838
}
3939

40+
# Get the partition name of the /boot file system
41+
get_boot_partition_name() {
42+
local paths="/boot"
43+
local partition_name
44+
45+
partition_name=$(df "${paths}" | awk 'NR==2 {print $1}' | awk -F '/' '{print $3}')
46+
47+
echo "${partition_name}"
48+
}
49+
4050
# Get the partition name of the root file system
4151
get_root_partition_name() {
4252
local paths=("/" "/overlay" "/rom")
@@ -47,7 +57,6 @@ get_root_partition_name() {
4757
[[ -n "${partition_name}" ]] && break
4858
done
4959

50-
[[ -z "${partition_name}" ]] && error_msg "Cannot find the root partition!"
5160
echo "${partition_name}"
5261
}
5362

@@ -91,6 +100,12 @@ init_var() {
91100
support_platform=("allwinner" "rockchip" "amlogic" "qemu-aarch64")
92101
[[ -n "$(echo "${support_platform[@]}" | grep -w "${PLATFORM}")" ]] || error_msg "[ ${PLATFORM} ] is not supported."
93102

103+
# Check and repair partition mount points
104+
[[ -z "$(get_boot_partition_name)" || -z "$(get_root_partition_name)" ]] && {
105+
echo -e "Partition mount point error, start repairing..."
106+
openwrt-backup -g
107+
}
108+
94109
# Set /boot/vmlinuz-* replication names for different SoCs
95110
MYBOOT_VMLINUZ="$(ls -l /boot/*Image 2>/dev/null | awk '{print $9}' | head -n 1)"
96111
MYBOOT_VMLINUZ="${MYBOOT_VMLINUZ##*/}"
@@ -268,8 +283,8 @@ update_kernel() {
268283
rm -f /boot/uInitrd*
269284
else
270285
valid_files="vmlinuz-${kernel_name} uInitrd-${kernel_name} config-${kernel_name} System.map-${kernel_name}"
271-
# wxy-oect: MODEL_ID numbers r304 and r306, require special handling of uInitrd
272-
[[ "${MODEL_ID}" =~ ^(r304|r306)$ ]] || rm -f /boot/initrd.img*
286+
# wxy-oect: MODEL_ID numbers r304,r306 and w[0-9]{3}, require special handling of uInitrd
287+
[[ "${MODEL_ID}" =~ ^(r304|r306|w[0-9]{3})$ ]] || rm -f /boot/initrd.img*
273288
fi
274289
for f in ${valid_files}; do [[ -f "/boot/${f}" ]] || restore_kernel; done
275290

luci-app-amlogic/root/usr/sbin/openwrt-update-allwinner

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ error_msg() {
2121
exit 1
2222
}
2323

24+
# Get the partition name of the /boot file system
25+
get_boot_partition_name() {
26+
local paths="/boot"
27+
local partition_name
28+
29+
partition_name=$(df "${paths}" | awk 'NR==2 {print $1}' | awk -F '/' '{print $3}')
30+
31+
echo "${partition_name}"
32+
}
33+
2434
# Get the partition name of the root file system
2535
get_root_partition_name() {
2636
local paths=("/" "/overlay" "/rom")
@@ -31,7 +41,6 @@ get_root_partition_name() {
3141
[[ -n "${partition_name}" ]] && break
3242
done
3343

34-
[[ -z "${partition_name}" ]] && error_msg "Cannot find the root partition!"
3544
echo "${partition_name}"
3645
}
3746

@@ -79,6 +88,12 @@ else
7988
sleep 3
8089
fi
8190

91+
# Check and repair partition mount points
92+
[[ -z "$(get_boot_partition_name)" || -z "$(get_root_partition_name)" ]] && {
93+
echo -e "Partition mount point error, start repairing..."
94+
openwrt-backup -g
95+
}
96+
8297
# Find the partition where root is located
8398
ROOT_PTNAME="$(get_root_partition_name)"
8499

luci-app-amlogic/root/usr/sbin/openwrt-update-amlogic

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ error_msg() {
2121
exit 1
2222
}
2323

24+
# Get the partition name of the /boot file system
25+
get_boot_partition_name() {
26+
local paths="/boot"
27+
local partition_name
28+
29+
partition_name=$(df "${paths}" | awk 'NR==2 {print $1}' | awk -F '/' '{print $3}')
30+
31+
echo "${partition_name}"
32+
}
33+
2434
# Get the partition name of the root file system
2535
get_root_partition_name() {
2636
local paths=("/" "/overlay" "/rom")
@@ -31,7 +41,6 @@ get_root_partition_name() {
3141
[[ -n "${partition_name}" ]] && break
3242
done
3343

34-
[[ -z "${partition_name}" ]] && error_msg "Cannot find the root partition!"
3544
echo "${partition_name}"
3645
}
3746

@@ -65,6 +74,12 @@ else
6574
sleep 3
6675
fi
6776

77+
# Check and repair partition mount points
78+
[[ -z "$(get_boot_partition_name)" || -z "$(get_root_partition_name)" ]] && {
79+
echo -e "Partition mount point error, start repairing..."
80+
openwrt-backup -g
81+
}
82+
6883
# Find the partition where root is located
6984
ROOT_PTNAME="$(get_root_partition_name)"
7085

luci-app-amlogic/root/usr/sbin/openwrt-update-kvm

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ error_msg() {
2121
exit 1
2222
}
2323

24+
# Get the partition name of the /boot file system
25+
get_boot_partition_name() {
26+
local paths="/boot"
27+
local partition_name
28+
29+
partition_name=$(df "${paths}" | awk 'NR==2 {print $1}' | awk -F '/' '{print $3}')
30+
31+
echo "${partition_name}"
32+
}
33+
2434
# Get the partition name of the root file system
2535
get_root_partition_name() {
2636
local paths=("/" "/overlay" "/rom")
@@ -31,7 +41,6 @@ get_root_partition_name() {
3141
[[ -n "${partition_name}" ]] && break
3242
done
3343

34-
[[ -z "${partition_name}" ]] && error_msg "Cannot find the root partition!"
3544
echo "${partition_name}"
3645
}
3746

@@ -79,6 +88,12 @@ else
7988
sleep 3
8089
fi
8190

91+
# Check and repair partition mount points
92+
[[ -z "$(get_boot_partition_name)" || -z "$(get_root_partition_name)" ]] && {
93+
echo -e "Partition mount point error, start repairing..."
94+
openwrt-backup -g
95+
}
96+
8297
# Find the partition where root is located
8398
# vda2 or vda3
8499
ROOT_PTNAME="$(get_root_partition_name)"

luci-app-amlogic/root/usr/sbin/openwrt-update-rockchip

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ error_msg() {
2121
exit 1
2222
}
2323

24+
# Get the partition name of the /boot file system
25+
get_boot_partition_name() {
26+
local paths="/boot"
27+
local partition_name
28+
29+
partition_name=$(df "${paths}" | awk 'NR==2 {print $1}' | awk -F '/' '{print $3}')
30+
31+
echo "${partition_name}"
32+
}
33+
2434
# Get the partition name of the root file system
2535
get_root_partition_name() {
2636
local paths=("/" "/overlay" "/rom")
@@ -31,7 +41,6 @@ get_root_partition_name() {
3141
[[ -n "${partition_name}" ]] && break
3242
done
3343

34-
[[ -z "${partition_name}" ]] && error_msg "Cannot find the root partition!"
3544
echo "${partition_name}"
3645
}
3746

@@ -303,6 +312,12 @@ esac
303312
echo -e "Current device: ${MYDEVICE_NAME} [ ${SOC} ]"
304313
sleep 3
305314

315+
# Check and repair partition mount points
316+
[[ -z "$(get_boot_partition_name)" || -z "$(get_root_partition_name)" ]] && {
317+
echo -e "Partition mount point error, start repairing..."
318+
openwrt-backup -g
319+
}
320+
306321
# Find the partition where root is located
307322
ROOT_PTNAME="$(get_root_partition_name)"
308323

@@ -747,7 +762,7 @@ sed -e 's/ttyAMA0/ttyS2/' -i ./etc/inittab
747762
[ "${SOC}" != "ht2" ] && \
748763
[ "${SOC}" != "e20c" ] && \
749764
[ "${SOC}" != "e24c" ] && \
750-
sed -e 's/ttyS0/tty1/' -i ./etc/inittab
765+
sed -e 's/ttyS0/tty1/' -i ./etc/inittab
751766

752767
sss=$(date +%s)
753768
ddd=$((sss / 86400))

0 commit comments

Comments
 (0)