From 87dead9920ef1534536a7feaedc61fa9defbfdb4 Mon Sep 17 00:00:00 2001 From: vincent Date: Wed, 30 Sep 2020 14:24:45 +0200 Subject: [PATCH] better share start script, retrofe improvements --- .../rootfs-overlay/usr/local/sbin/share | 61 +++++-------------- FunKey/package/retrofe/retrofe.mk | 2 +- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share index c9ef30b..e2915ec 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share @@ -81,6 +81,22 @@ stop_share () { return 0 } +# Start sharing the backing store partition +start_share () { + + # 1) Check if the backing store partition is already shared + cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 && die 12 "the backing store partition is already shared" + + # 2) Check if USB data is connected + is_usb_data_connected > /dev/null 2>&1 || die 13 "USB sharing impossible, not connected to a host" + + # 3) Unmount the backing store partition if it is locally mounted + unmount_share + + # 4) Everything is now clear to start sharing the backing store partition + info "start sharing the backing store partition" + echo /dev/mmcblk0p3 > $BACKING_STORE_FILE || die 14 "cannot share the backing store partition" +} # Return if currently sharing is_share_started () { @@ -95,51 +111,6 @@ is_share_started () { return $res } -# Start sharing the backing store partition -start_share () { - - # 1) Check if the backing store partition is already shared - cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 && die 12 "the backing store partition is already shared" - - # 2) Unmount the backing store partition if it is locally mounted - unmount_share - - # Everything is now clear to start sharing the backing store partition - info "start sharing the backing store partition" - echo /dev/mmcblk0p3 > $BACKING_STORE_FILE || die 13 "cannot share the backing store partition" - - # Check if we are connected to an USB host - local trials=0 - local not_ready=1 - while [ ${trials} -lt 5 -a ${not_ready} -eq 1 ]; do - - # Get connection state - local udc_state=$(cat /sys/class/udc/musb-hdrc.1.auto/state) - sleep 1 - let trials=$trials+1 - - # Check if USB is connected - if [ x"$udc_state" == "xconfigured" ]; then - - # Connected succesfully to a host - info "backing store file shared" - return 0 - elif [ x"$udc_state" == "xdefault" ]; then - - # Connected succesfully to a host - info "USB sharing in progress" - else - # Connection failed - not_ready=0 - fi - done - - # No USB host connected - warn "no host, stop USB sharing" - stop_share - die 14 "not connected to a host" -} - case "$1" in init) diff --git a/FunKey/package/retrofe/retrofe.mk b/FunKey/package/retrofe/retrofe.mk index 7f2b7e6..3226ead 100644 --- a/FunKey/package/retrofe/retrofe.mk +++ b/FunKey/package/retrofe/retrofe.mk @@ -4,7 +4,7 @@ # ################################################################################ -RETROFE_VERSION = f561c02646ef4400a3d9a6cef0d1f4946f3ce5c8 +RETROFE_VERSION = 10fcd1bcc7d0a9faa5278b004fd21be89513b564 RETROFE_SITE_METHOD = git #RETROFE_SITE = ssh://git@github.com/FunKey-Project/FunKey-Launcher-retrofe.git RETROFE_SITE = ssh://git@fk/FunKey-Project/FunKey-Launcher-retrofe.git