From 3588c777ca7ba7ee9d95d71b36e6ce6e5279ac99 Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 1 Nov 2020 16:33:32 +0100 Subject: [PATCH 1/4] redirect dropbear keys to /tmp Signed-off-by: Michel-FK --- Recovery/board/funkey/post-build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Recovery/board/funkey/post-build.sh b/Recovery/board/funkey/post-build.sh index bdc9716..885e400 100755 --- a/Recovery/board/funkey/post-build.sh +++ b/Recovery/board/funkey/post-build.sh @@ -10,5 +10,9 @@ rm -f ${TARGET_DIR}/etc/init.d/S01syslogd ${TARGET_DIR}/etc/init.d/S02klogd # Change dropbear init sequence mv ${TARGET_DIR}/etc/init.d/S50dropbear ${TARGET_DIR}/etc/init.d/S42dropbear +# Redirect drobear keys to /tmp +rm ${TARGET_DIR}/etc/dropbear +ln -s /tmp ${TARGET_DIR}/etc/dropbear + # Generate U-Boot environment ${HOST_DIR}/bin/mkenvimage -p 0x0 -s 0x20000 -o ${BINARIES_DIR}/u-boot-env.img ${TARGET_DIR}/etc/u-boot.env From 079ca21426e3070b5d9b10bf3de700366219473f Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 1 Nov 2020 16:33:58 +0100 Subject: [PATCH 2/4] add ro and rw helper scripts Signed-off-by: Michel-FK --- Recovery/board/funkey/rootfs-overlay/usr/local/sbin/ro | 3 +++ Recovery/board/funkey/rootfs-overlay/usr/local/sbin/rw | 3 +++ 2 files changed, 6 insertions(+) create mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/ro create mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/rw diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/ro b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/ro new file mode 100755 index 0000000..4501fa9 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/ro @@ -0,0 +1,3 @@ +#!/bin/sh + +mount / -o remount,ro diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/rw b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/rw new file mode 100755 index 0000000..4c33730 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/rw @@ -0,0 +1,3 @@ +#!/bin/sh + +mount / -o remount,rw From ed8902c09ab4009a3fb632d2aa2b0ae7ad0d1d8e Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 1 Nov 2020 16:34:21 +0100 Subject: [PATCH 3/4] disable network & factory test when USB is mounted make menu wrap up add sapce berfore each entry center restarting notif Signed-off-by: Michel-FK --- .../funkey/rootfs-overlay/usr/local/sbin/menu | 105 ++++++++++++------ 1 file changed, 69 insertions(+), 36 deletions(-) diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu index 705bd19..4b92398 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu @@ -2,6 +2,12 @@ source /usr/local/lib/utils +# Get a key +getkey() { + local key=$(dd if=/dev/input/event0 bs=32 count=1 status=none | xxd -p -c 32 | cut -b 21-26) + echo ${key} +} + # Display meny item menu_display () { local entry=${1} @@ -13,54 +19,54 @@ menu_display () { # USB mount/unmount mount | grep -q /dev/mmcblk0p3 if [ $? -eq 0 ]; then - message="USB mount" + message=" USB mount" else - message="USB unmount" + message=" USB unmount" fi ;; 1) # USB check - message="USB check" + message=" USB check" ;; 2) # USB format - message="USB format" + message=" USB format" ;; 3) # Network enable/disable if [ -e /mnt/usbnet ]; then - message="Network disable" + message=" Network disable" else - message="Network enable" + message=" Network enable" fi ;; 4) # QR code - message="QR code" + message=" QR code" ;; 5) # Factory tests enable/disable if [ -e /mnt/.assembly_tests ]; then - message="Factory tests disable" + message=" Factory tests disable" else - message="Factory tests enable" + message=" Factory tests enable" fi ;; 6) # Exit Recovery - message="Exit Recovery" + message=" Exit Recovery" ;; esac notif "${message}" @@ -81,7 +87,7 @@ menu_run () { if [ $? -ne 0 ]; then notif "${message}...^Cannot mount USB!" else - message="USB unmount" + message=" USB unmount" notif "${message}" fi else @@ -97,7 +103,7 @@ menu_run () { break fi done - message="USB mount" + message=" USB mount" notif "${message}" fi fi @@ -133,15 +139,30 @@ menu_run () { # USB format mount | grep -q /dev/mmcblk0p3 if [ $? -eq 0 ]; then - notif "${message}..." - umount /mnt && - mkfs.vfat /dev/mmcblk0p3 && - mount /mnt - if [ $? -ne 0 ]; then - notif "${message}...^Cannot format USB!" - else - notif "${message} done" - fi + notif "${message}...^Press A to confirm" + while true; do + case $(getkey) in + 1e0001|1e0002) + umount /mnt && + mkfs.vfat /dev/mmcblk0p3 && + mount /mnt + if [ $? -ne 0 ]; then + notif "${message}...^Cannot format USB!" + else + notif "${message} done" + fi + break + ;; + + 1e0000) + ;; + + *) + notif "${message}...^Aborted!" + break + ;; + esac + done else notif "${message}...^Cannot format USB when mounted!" fi @@ -150,14 +171,19 @@ menu_run () { 3) # Network enable/disable - if [ -e /mnt/usbnet ]; then - rm -f /mnt/usbnet - message="Network enable" + mount | grep -q /dev/mmcblk0p3 + if [ $? -eq 0 ]; then + if [ -e /mnt/usbnet ]; then + rm -f /mnt/usbnet + message=" Network enable" + else + touch /mnt/usbnet + message=" Network disable" + fi + notif "${message}" else - touch /mnt/usbnet - message="Network disable" + notif "${message}...^Cannot change net if mounted!" fi - notif "${message}" ;; 4) @@ -170,18 +196,23 @@ menu_run () { 5) # Factory tests enable/disable - if [ -e /mnt/.assembly_tests ]; then - rm -f /mnt/.assembly_tests - message="Factory tests enable" + mount | grep -q /dev/mmcblk0p3 + if [ $? -eq 0 ]; then + if [ -e /mnt/.assembly_tests ]; then + rm -f /mnt/.assembly_tests + message=" Factory tests enable" + else + touch /mnt/.assembly_tests + message=" Factory tests disable" + fi + notif "${message}" else - touch /mnt/.assembly_tests - message="Factory tests disable" + notif "${message}...^Cannot test if mounted!" fi - notif "${message}" ;; 6) - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode ;; esac @@ -195,13 +226,15 @@ menu_display ${entry} while true; do # Get key events - key=$(dd if=/dev/input/event0 bs=32 count=1 status=none | xxd -p -c 32 | cut -b 21-26) - case ${key} in + case $(getkey) in 160001|160002) # Key UP pressed or repeat let entry=${entry}-1 let entry=${entry}%7 + if [ ${entry} -eq -1 ]; then + entry=6 + fi menu_display ${entry} ;; From 8d936603cacbcd9d62c0a718652af4b7892fe515 Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 1 Nov 2020 16:41:10 +0100 Subject: [PATCH 4/4] removed tinyurl Signed-off-by: Michel-FK --- Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu index 4b92398..4a37dd9 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu @@ -189,7 +189,7 @@ menu_run () { 4) # QR code - qrencode -o /tmp/qrcode.png "https://tinyurl.com/y63qlwzu/$(get_sid)" + qrencode -o /tmp/qrcode.png "https://www.funkey-project.com/_functions/qrcode/$(get_sid)" fbv -e /tmp/qrcode.png -d 1 ;;