check if backing store exists beforehand

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2020-11-01 00:52:36 +01:00
parent b298d02d87
commit 4c3b75801a
1 changed files with 7 additions and 1 deletions

View File

@ -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