From 4c3b75801aedf2fb72ebc065c7ca4a7a18b7477c Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sun, 1 Nov 2020 00:52:36 +0100 Subject: [PATCH] check if backing store exists beforehand Signed-off-by: Michel-FK --- Recovery/board/funkey/rootfs-overlay/usr/local/sbin/share | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/share b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/share index e2915ec..97e28ba 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/share +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/share @@ -85,7 +85,9 @@ stop_share () { 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" + if [ -e $BACKING_STORE_FILE ]; then + cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 && die 12 "the backing store partition is already shared" + fi # 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" @@ -101,6 +103,10 @@ start_share () { # Return if currently sharing is_share_started () { + if [ ! -e $BACKING_STORE_FILE ]; then + echo "no" + return 1 + fi cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 local res=$? if [ "$res" == "0" ]; then