diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-09-04 19:26:17 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-09-04 19:26:17 +0300 |
commit | 00e8c777fc8e3d7dd7193ffcdc16f49c7724e28b (patch) | |
tree | a1d740f8caab20b43911ebe2500085e80d4605ed /etc/nextcloudpi-config.d/samba.sh | |
parent | 4074edaa11742b0020c0d0763f72472cac4886d3 (diff) |
samba: always use NC datadirv0.26.8
Diffstat (limited to 'etc/nextcloudpi-config.d/samba.sh')
-rw-r--r-- | etc/nextcloudpi-config.d/samba.sh | 18 |
1 files 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 <<EOF [NextCloudPi] - path = $DIR_ + path = $DIR writeable = yes ; browseable = yes valid users = $USER_ @@ -76,7 +82,7 @@ EOF usermod -aG www-data $USER_ echo -e "$PWD_\n$PWD_" | smbpasswd -s -a $USER_ - sudo chmod g+w $DIR_ + sudo chmod g+w $DIR echo "SMB enabled" } |