Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2018-02-09 14:22:29 +0300
committernachoparker <nacho@ownyourbits.com>2018-02-13 22:05:37 +0300
commitcac81ec0f062116931fc63a0a09e95360e58968a (patch)
tree8489e8c2c61fcf5db4ded0fd3bd8551faff9d6c8
parent30a8bdd213767a1f5d1ac129bc53a23799735549 (diff)
samba: create share per NC userv0.46.10
-rw-r--r--changelog.md10
-rw-r--r--etc/nextcloudpi-config.d/samba.sh52
2 files changed, 47 insertions, 15 deletions
diff --git a/changelog.md b/changelog.md
index 0bf8acb5..881adb1f 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,7 +1,13 @@
-[v0.46.7](https://github.com/nextcloud/nextcloudpi/commit/5eba8d6) (2018-02-12) update: fix typo in check version
+[v0.46.10](https://github.com/nextcloud/nextcloudpi/commit/b2c809c) (2018-02-09) samba: create share per NC user
-[v0.46.6](https://github.com/nextcloud/nextcloudpi/commit/9101b0d) (2018-02-08) Update ncp-check-version
+[v0.46.9](https://github.com/nextcloud/nextcloudpi/commit/19ccdb4) (2018-02-13) letsencrypt: only call update-rc.d in docker builds
+
+[v0.46.8 ](https://github.com/nextcloud/nextcloudpi/commit/354c767) (2018-02-12) preactivate useful apps for a selfhosted instance
+
+[v0.46.7 ](https://github.com/nextcloud/nextcloudpi/commit/5fd3cfa) (2018-02-12) update: fix typo in check version
+
+[v0.46.6 ](https://github.com/nextcloud/nextcloudpi/commit/9101b0d) (2018-02-08) Update ncp-check-version
[v0.46.5 ](https://github.com/nextcloud/nextcloudpi/commit/69242d0) (2018-02-09) nc-backup: stronger permissions for backup file
diff --git a/etc/nextcloudpi-config.d/samba.sh b/etc/nextcloudpi-config.d/samba.sh
index 09b0f789..5dae603d 100644
--- a/etc/nextcloudpi-config.d/samba.sh
+++ b/etc/nextcloudpi-config.d/samba.sh
@@ -14,8 +14,6 @@
#
ACTIVE_=no
-NCUSER_=admin
-USER_=ncp
PWD_=ownyourbits
DESCRIPTION="SMB/CIFS file server (for Mac/Linux/Windows)"
@@ -40,6 +38,11 @@ install()
# disable the [homes] share by default
sed -i /\[homes\]/s/homes/homes_disabled_ncp/ /etc/samba/smb.conf
+
+ cat >> /etc/samba/smb.conf <<EOF
+
+# NextCloudPi automatically generated from here. Do not remove this comment
+EOF
}
configure()
@@ -55,32 +58,55 @@ configure()
}
[ -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
+
+ # remove files from this line to the end
+ sed -i '/# NextCloudPi automatically/,/\$/d' /etc/samba/smb.conf
+
+ # restore this line
cat >> /etc/samba/smb.conf <<EOF
-[NextCloudPi]
- path = $DIR
- writeable = yes
+# NextCloudPi automatically generated from here. Do not remove this comment
+EOF
+
+ # create a share per Nextcloud user
+ local USERS=()
+ while read -r path; do
+ USERS+=( "$( basename $( dirname "$path" ) )" )
+ done < <( ls -d "$DATADIR"/*/files )
+
+ for user in ${USERS[@]}; do
+ echo "adding SAMBA share for user $user"
+ local DIR="$DATADIR/$user/files"
+ [ -d "$DIR" ] || { echo -e "INFO: directory $DIR does not exist."; return 1; }
+
+ cat >> /etc/samba/smb.conf <<EOF
+
+[ncp-$user]
+ path = $DIR
+ writeable = yes
; browseable = yes
- valid users = $USER_
+ valid users = $user
force group = www-data
create mask = 0770
directory mask = 0771
force create mode = 0660
force directory mode = 0770
+
EOF
+ ## create user with no login if it doesn't exist
+ id "$user" &>/dev/null || adduser --disabled-password --gecos "" "$user"
+ echo -e "$PWD_\n$PWD_" | smbpasswd -s -a $user
+
+ usermod -aG www-data $user
+ sudo chmod g+w $DIR
+ done
+
update-rc.d smbd defaults
update-rc.d smbd enable
service smbd start
- usermod -aG www-data $USER_
- echo -e "$PWD_\n$PWD_" | smbpasswd -s -a $USER_
- sudo chmod g+w $DIR
echo "SMB enabled"
}