From 00e8c777fc8e3d7dd7193ffcdc16f49c7724e28b Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 4 Sep 2017 18:26:17 +0200 Subject: samba: always use NC datadir --- etc/nextcloudpi-config.d/samba.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/etc/nextcloudpi-config.d/samba.sh b/etc/nextcloudpi-config.d/samba.sh index e8dc0256..b94d48ef 100644 --- a/etc/nextcloudpi-config.d/samba.sh +++ b/etc/nextcloudpi-config.d/samba.sh @@ -14,7 +14,7 @@ # ACTIVE_=no -DIR_=/media/USBdrive/ncdata/admin/files +NCUSER_=admin USER_=pi PWD_=raspberry DESCRIPTION="SMB/CIFS file server (for Mac/Linux/Windows)" @@ -50,16 +50,22 @@ configure() # CHECKS ################################ - [ -d "$DIR_" ] || { echo -e "INFO: directory $DIR_ does not exist. Creating"; mkdir -p "$DIR_"; } - [[ $( stat -fc%d / ) == $( stat -fc%d $DIR_ ) ]] && \ - echo -e "INFO: working in the SD card\nIf you want to use an external mount, make sure it is properly set up" + local DATADIR + DATADIR=$( sudo -u www-data /var/www/nextcloud/occ config:system:get datadirectory ) || { + echo -e "Error reading data directory. Is NextCloud running and configured?"; + return 1; + } + [ -d "$DATADIR" ] || { echo -e "data directory $DATADIR not found" ; return 1; } + + local DIR="$DATADIR/$NCUSER_/files" + [ -d "$DIR" ] || { echo -e "INFO: directory $DIR does not exist."; return 1; } # CONFIG ################################ sed -i '/\[NextCloudPi\]/,+10d' /etc/samba/smb.conf cat >> /etc/samba/smb.conf <