LibreELEC-settings: add support for workgroup, server min/max proto settings

This commit is contained in:
MilhouseVH 2017-08-27 08:18:06 +01:00
parent f8b307e193
commit 33e4f03a40
3 changed files with 18 additions and 1 deletions

View File

@ -22,7 +22,6 @@
[global]
server string = LibreELEC
workgroup = WORKGROUP
browseable = yes
writeable = yes
printable = no

View File

@ -2,3 +2,6 @@ SAMBA_AUTOSHARE="true"
SAMBA_USERNAME="libreelec"
SAMBA_PASSWORD="libreelec"
SAMBA_SECURE="false"
SAMBA_MINPROTOCOL="SMB2"
SAMBA_MAXPROTOCOL="SMB3"
SAMBA_WORKGROUP="WORKGROUP"

View File

@ -35,6 +35,21 @@ if [ "$SAMBA_AUTOSHARE" == "true" ] ; then
done
fi
ADD_CONFIG=
# If workgroup is not set, don't set it - who knows, user may know better.
if [ -n "$SAMBA_WORKGROUP" ]; then
# Remove any existing workgroup setting
sed -E '/^[[:space:]]*workgroup[[:space:]]*=/d' -i $SMB_CONF
ADD_CONFIG="${ADD_CONFIG} workgroup = ${SAMBA_WORKGROUP:-WORKGROUP}\n"
fi
ADD_CONFIG="${ADD_CONFIG} server min protocol = ${SAMBA_MINPROTOCOL/SMB1/NT1}\n"
ADD_CONFIG="${ADD_CONFIG} server max protocol = ${SAMBA_MAXPROTOCOL/SMB1/NT1}\n"
# Add extra config after [global], escaping spaces so that all are retained by sed
sed -e "/\[global\]/ a ${ADD_CONFIG// /\\ }" -i $SMB_CONF
# only letters & numbers permitted for username & password
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
SAMBA_PASSWORD=`echo $SAMBA_PASSWORD | sed "s/[^a-zA-Z0-9]//g;"`