mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge pull request #2994 from mglae/le9_samba_config
samba-config.service: fix destroying .cache structure
This commit is contained in:
commit
fc00843b3f
@ -4,6 +4,9 @@
|
|||||||
# Copyright (C) 2009-2017 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2017 Stephan Raue (stephan@openelec.tv)
|
||||||
|
|
||||||
SMB_CONF="/run/samba/smb.conf"
|
SMB_CONF="/run/samba/smb.conf"
|
||||||
|
SMB_TMP="$(mktemp -p /run/samba)"
|
||||||
|
|
||||||
|
cp -f $SMB_CONF $SMB_TMP
|
||||||
|
|
||||||
if [ ! -f /storage/.cache/services/samba.conf ]; then
|
if [ ! -f /storage/.cache/services/samba.conf ]; then
|
||||||
cp /usr/share/services/samba.conf /storage/.cache/services
|
cp /usr/share/services/samba.conf /storage/.cache/services
|
||||||
@ -17,21 +20,21 @@ SAMBA_MAXPROTOCOL=SMB3
|
|||||||
. /storage/.cache/services/samba.conf
|
. /storage/.cache/services/samba.conf
|
||||||
|
|
||||||
# fixup synonyms
|
# fixup synonyms
|
||||||
sed -i 's/browsable/browseable/g; s/writable/writeable/g' $SMB_CONF
|
sed -i 's/browsable/browseable/g; s/writable/writeable/g' $SMB_TMP
|
||||||
|
|
||||||
# handle external drives
|
# handle external drives
|
||||||
if [ "$SAMBA_AUTOSHARE" == "true" ] ; then
|
if [ "$SAMBA_AUTOSHARE" == "true" ] ; then
|
||||||
for dir in /media/* ; do
|
for dir in /media/* ; do
|
||||||
if [ -d "$dir" ] ; then
|
if [ -d "$dir" ] ; then
|
||||||
name=$(basename "$dir")
|
name=$(basename "$dir")
|
||||||
echo -e "[$name]\n path = $dir\n available = yes\n browseable = yes\n public = yes\n writeable = yes\n" >> $SMB_CONF
|
echo -e "[$name]\n path = $dir\n available = yes\n browseable = yes\n public = yes\n writeable = yes\n" >> $SMB_TMP
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allow access to a "failed" (safe mode) Kodi installation
|
# Allow access to a "failed" (safe mode) Kodi installation
|
||||||
if [ -d /storage/.kodi.FAILED ]; then
|
if [ -d /storage/.kodi.FAILED ]; then
|
||||||
echo -e "[Kodi-Failed]\n path = /storage/.kodi.FAILED\n available = yes\n browseable = yes\n public = yes\n writeable = yes\n" >> $SMB_CONF
|
echo -e "[Kodi-Failed]\n path = /storage/.kodi.FAILED\n available = yes\n browseable = yes\n public = yes\n writeable = yes\n" >> $SMB_TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ADD_CONFIG=
|
ADD_CONFIG=
|
||||||
@ -39,7 +42,7 @@ ADD_CONFIG=
|
|||||||
# If workgroup is not set, don't set it - who knows, user may know better.
|
# If workgroup is not set, don't set it - who knows, user may know better.
|
||||||
if [ -n "$SAMBA_WORKGROUP" ]; then
|
if [ -n "$SAMBA_WORKGROUP" ]; then
|
||||||
# Remove any existing workgroup setting
|
# Remove any existing workgroup setting
|
||||||
sed -E '/^[[:space:]]*workgroup[[:space:]]*=/d' -i $SMB_CONF
|
sed -E '/^[[:space:]]*workgroup[[:space:]]*=/d' -i $SMB_TMP
|
||||||
ADD_CONFIG="${ADD_CONFIG} workgroup = ${SAMBA_WORKGROUP:-WORKGROUP}\n"
|
ADD_CONFIG="${ADD_CONFIG} workgroup = ${SAMBA_WORKGROUP:-WORKGROUP}\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -47,7 +50,7 @@ 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_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
|
# Add extra config after [global], escaping spaces so that all are retained by sed
|
||||||
sed -e "/\[global\]/ a ${ADD_CONFIG// /\\ }" -i $SMB_CONF
|
sed -e "/\[global\]/ a ${ADD_CONFIG// /\\ }" -i $SMB_TMP
|
||||||
|
|
||||||
# only letters & numbers permitted for username & password
|
# only letters & numbers permitted for username & password
|
||||||
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
|
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
|
||||||
@ -65,11 +68,13 @@ if [ "$SAMBA_SECURE" == "true" -a ! "$SAMBA_USERNAME" == "" -a ! "$SAMBA_PASSWOR
|
|||||||
-e 's|^.[ \t]*.username map.=.*||' \
|
-e 's|^.[ \t]*.username map.=.*||' \
|
||||||
-e 's|^.[ \t]*.security.=.*| security = user\n username map = /run/samba/samba.map|' \
|
-e 's|^.[ \t]*.security.=.*| security = user\n username map = /run/samba/samba.map|' \
|
||||||
-e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Never|' \
|
-e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Never|' \
|
||||||
-i $SMB_CONF
|
-i $SMB_TMP
|
||||||
else
|
else
|
||||||
sed -e 's|^.[ \t]*.public.=.*| public = yes |' \
|
sed -e 's|^.[ \t]*.public.=.*| public = yes |' \
|
||||||
-e 's|^.[ \t]*.username map.=.*||' \
|
-e 's|^.[ \t]*.username map.=.*||' \
|
||||||
-e 's|^.[ \t]*.security.=.*| security = user|' \
|
-e 's|^.[ \t]*.security.=.*| security = user|' \
|
||||||
-e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Bad User|' \
|
-e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Bad User|' \
|
||||||
-i $SMB_CONF
|
-i $SMB_TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mv -f $SMB_TMP $SMB_CONF
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Samba Configuration
|
Description=Samba Configuration
|
||||||
DefaultDependencies=false
|
DefaultDependencies=false
|
||||||
|
After=basic.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/lib/samba/samba-config
|
ExecStart=/usr/lib/samba/samba-config
|
||||||
StartLimitInterval=0
|
StartLimitInterval=0
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=sysinit.target
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
|
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
|
||||||
|
|
||||||
|
# Fix bug in older versions creating file /storage/.cache/services
|
||||||
|
[ -f /storage/.cache/services ] && rm /storage/.cache/services && mkdir -p /storage/.cache/services
|
||||||
|
|
||||||
# Copy cache files, but don't overwrite
|
# Copy cache files, but don't overwrite
|
||||||
false | cp -iRp /usr/cache/* /storage/.cache/ &>/dev/null
|
false | cp -iRp /usr/cache/* /storage/.cache/ &>/dev/null
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user