Files
wlan-ap/feeds/tip/certificates/files/usr/bin/mount_certs
Jesse Wu 919fe12372 ipq807x: add EMPLUS WAP380C support
Fixes: WIFI-14791
Signed-off-by: Jesse Wu <Jesse.Wu@emplustech.com>
2025-07-08 08:13:39 +02:00

135 lines
2.7 KiB
Bash
Executable File

#!/bin/sh
check_certificates() {
[ -f /certificates/cert.pem -a -f /certificates/key.pem ] && exit 0
}
check_certificates
bootconfig_lookup() {
case "$(fw_printenv -n cert_part)" in
0) echo "0:BOOTCONFIG"
;;
1) echo "0:BOOTCONFIG1"
;;
esac
}
. /lib/functions.sh
mkdir -p /certificates /etc/ucentral/
case "$(board_name)" in
cig,wf660a)
mmc_dev=$(echo $(find_mmc_part "0:ETHPHYFW") | sed 's/^.\{5\}//')
[ -n "$mmc_dev" ] && mount -t ext4 /dev/$mmc_dev /certificates
;;
cig,wf672)
mmc_dev=$(echo $(find_mmc_part "cert") | sed 's/^.\{5\}//')
[ -n "$mmc_dev" ] && mount -t ext4 /dev/$mmc_dev /certificates
;;
sonicfi,rap7110c-341x)
mmc_dev=$(echo $(find_mmc_part "certificates") | sed 's/^.\{5\}//')
[ -n "$mmc_dev" ] && mount -t squashfs /dev/$mmc_dev /mnt
bootconfig=$(bootconfig_lookup)
if [ -n "$bootconfig" ]; then
mmc_dev=$(echo $(find_mmc_part "$bootconfig") | sed 's/^.\{5\}//')
[ -n "$mmc_dev" ] && tar xf /dev/$mmc_dev -C /certificates
else
cp /mnt/* /certificates/
umount /mnt
fi
;;
*)
mtd=$(find_mtd_index certificates)
if [ "$(head -c 4 /dev/mtd$mtd)" == "hsqs" ]; then
mount -t squashfs /dev/mtdblock$mtd /certificates
else
[ -n "$mtd" -a -f /sys/class/mtd/mtd$mtd/oobsize ] && ubiattach -p /dev/mtd$mtd
if [ -n "$(ubinfo -a | grep certificates)" ]; then
[ -e /dev/ubi0 ] && mount -t ubifs ubi0:certificates /certificates
[ -e /dev/ubi1 ] && mount -t ubifs ubi1:certificates /certificates
fi
fi
esac
check_certificates
# if we get here no valid certificates were found
PART_NAME=
case "$(board_name)" in
actiontec,web7200)
if grep -q bootselect=0 /proc/cmdline; then
PART_NAME=firmware2
else
PART_NAME=firmware1
fi
;;
edgecore,ecw5211|\
edgecore,eap101|\
edgecore,eap102|\
edgecore,eap104|\
edgecore,eap105|\
edgecore,eap111|\
edgecore,eap112|\
edgecore,oap101|\
edgecore,oap101e|\
edgecore,oap101-6e|\
edgecore,oap101e-6e|\
edgecore,oap103)
if grep -q rootfs1 /proc/cmdline; then
PART_NAME=rootfs2
else
PART_NAME=rootfs1
fi
;;
hfcl,ion4xi|\
hfcl,ion4xi_w|\
hfcl,ion4x_w|\
hfcl,ion4xi_HMR|\
hfcl,ion4x|\
hfcl,ion4x_2|\
hfcl,ion4xi_wp|\
hfcl,ion4xe)
if grep -q rootfs_1 /proc/cmdline; then
PART_NAME=rootfs
else
PART_NAME=rootfs_1
fi
;;
cig,wf186w|\
cig,wf189|\
cig,wf189w|\
cig,wf189h|\
cig,wf186h|\
cig,wf196|\
cig,wf188n|\
emplus,wap380c|\
emplus,wap385c|\
emplus,wap386v2|\
emplus,wap581|\
yuncore,ax840|\
yuncore,fap655)
PART_NAME=rootfs_1
;;
senao,iap2300m|\
senao,iap4300m|\
emplus,wap588m|\
senao,jeap6500)
PART_NAME=ubi
;;
*)
return 1
;;
esac
MTD=$(find_mtd_index $PART_NAME)
[ -z "$MTD" ] && return 1
ubiattach -m $MTD -d 3
[ -e /dev/ubi3 ] && mount -t ubifs ubi3:certificates /certificates
check_certificates