mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 05:06:43 +00:00
Merge pull request #330 from escalade/sambafix
samba: move samba-defaults into the samba-config script
This commit is contained in:
commit
1ed40a16d6
@ -189,7 +189,6 @@ makeinstall_target() {
|
|||||||
|
|
||||||
post_install() {
|
post_install() {
|
||||||
if [ "$SAMBA_SERVER" = "yes" ]; then
|
if [ "$SAMBA_SERVER" = "yes" ]; then
|
||||||
enable_service samba-defaults.service
|
|
||||||
enable_service nmbd.service
|
enable_service nmbd.service
|
||||||
enable_service smbd.service
|
enable_service smbd.service
|
||||||
fi
|
fi
|
||||||
|
@ -21,44 +21,46 @@ SMB_USERCONF="/storage/.config/samba.conf"
|
|||||||
SMB_DEFCONF="/etc/samba/smb.conf"
|
SMB_DEFCONF="/etc/samba/smb.conf"
|
||||||
SMB_CONF="/run/samba/smb.conf"
|
SMB_CONF="/run/samba/smb.conf"
|
||||||
|
|
||||||
if [ -f /storage/.cache/services/samba.conf ]; then
|
if [ ! -f /storage/.cache/services/samba.conf ]; then
|
||||||
. /storage/.cache/services/samba.conf
|
/bin/cp /usr/share/services/samba.conf /storage/.cache/services
|
||||||
|
fi
|
||||||
mkdir -p /run/samba
|
|
||||||
if [ -f $SMB_USERCONF ]; then
|
. /storage/.cache/services/samba.conf
|
||||||
cp $SMB_USERCONF $SMB_CONF
|
|
||||||
else
|
mkdir -p /run/samba
|
||||||
cp $SMB_DEFCONF $SMB_CONF
|
if [ -f $SMB_USERCONF ]; then
|
||||||
fi
|
cp $SMB_USERCONF $SMB_CONF
|
||||||
|
else
|
||||||
# handle external drives
|
cp $SMB_DEFCONF $SMB_CONF
|
||||||
if [ "$SAMBA_AUTOSHARE" == "true" ] ; then
|
fi
|
||||||
for dir in /media/* ; do
|
|
||||||
if [ -d "$dir" ] ; then
|
# handle external drives
|
||||||
name=$(basename "$dir")
|
if [ "$SAMBA_AUTOSHARE" == "true" ] ; then
|
||||||
echo -e "[$name]\n path = $dir\n available = yes\n browsable = yes\n public = yes\n writable = yes\n" >> $SMB_CONF
|
for dir in /media/* ; do
|
||||||
fi
|
if [ -d "$dir" ] ; then
|
||||||
done
|
name=$(basename "$dir")
|
||||||
fi
|
echo -e "[$name]\n path = $dir\n available = yes\n browsable = yes\n public = yes\n writable = yes\n" >> $SMB_CONF
|
||||||
|
fi
|
||||||
# only letters & numbers permitted for username & password
|
done
|
||||||
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
|
fi
|
||||||
SAMBA_PASSWORD=`echo $SAMBA_PASSWORD | sed "s/[^a-zA-Z0-9]//g;"`
|
|
||||||
|
# only letters & numbers permitted for username & password
|
||||||
if [ "$SAMBA_SECURE" == "true" -a ! "$SAMBA_USERNAME" == "" -a ! "$SAMBA_PASSWORD" == "" ] ; then
|
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
|
||||||
# username map: first line makes sure plain root does not work all the time
|
SAMBA_PASSWORD=`echo $SAMBA_PASSWORD | sed "s/[^a-zA-Z0-9]//g;"`
|
||||||
# processing continues, so if user chooses root as username, second line overrides the first
|
|
||||||
# this is done always in case user uses passwords in userconf.
|
if [ "$SAMBA_SECURE" == "true" -a ! "$SAMBA_USERNAME" == "" -a ! "$SAMBA_PASSWORD" == "" ] ; then
|
||||||
# many thanks to viljoviitanen for this
|
# username map: first line makes sure plain root does not work all the time
|
||||||
echo -e "$SAMBA_PASSWORD\n$SAMBA_PASSWORD" | smbpasswd -s -a root >/dev/null 2>&1
|
# processing continues, so if user chooses root as username, second line overrides the first
|
||||||
echo -e "nobody = root\nroot = $SAMBA_USERNAME" > /var/run/samba.map
|
# this is done always in case user uses passwords in userconf.
|
||||||
|
# many thanks to viljoviitanen for this
|
||||||
sed -e 's|^.[ \t]*.public.=.*| public = no |' -i $SMB_CONF
|
echo -e "$SAMBA_PASSWORD\n$SAMBA_PASSWORD" | smbpasswd -s -a root >/dev/null 2>&1
|
||||||
sed -e 's|^.[ \t]*.username map.=.*||' -i $SMB_CONF
|
echo -e "nobody = root\nroot = $SAMBA_USERNAME" > /var/run/samba.map
|
||||||
sed -e 's|^.[ \t]*.security.=.*| security = user\n username map = /var/run/samba.map|' -i $SMB_CONF
|
|
||||||
else
|
sed -e 's|^.[ \t]*.public.=.*| public = no |' -i $SMB_CONF
|
||||||
sed -e 's|^.[ \t]*.public.=.*| public = yes |' -i $SMB_CONF
|
sed -e 's|^.[ \t]*.username map.=.*||' -i $SMB_CONF
|
||||||
sed -e 's|^.[ \t]*.username map.=.*||' -i $SMB_CONF
|
sed -e 's|^.[ \t]*.security.=.*| security = user\n username map = /var/run/samba.map|' -i $SMB_CONF
|
||||||
sed -e 's|^.[ \t]*.security.=.*| security = share|' -i $SMB_CONF
|
else
|
||||||
fi
|
sed -e 's|^.[ \t]*.public.=.*| public = yes |' -i $SMB_CONF
|
||||||
|
sed -e 's|^.[ \t]*.username map.=.*||' -i $SMB_CONF
|
||||||
|
sed -e 's|^.[ \t]*.security.=.*| security = share|' -i $SMB_CONF
|
||||||
fi
|
fi
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Samba NMB Daemon
|
Description=Samba NMB Daemon
|
||||||
After=network.target samba-config.service
|
After=network.target smbd.service
|
||||||
Requires=samba-config.service
|
|
||||||
|
|
||||||
ConditionPathExists=/storage/.cache/services/samba.conf
|
|
||||||
ConditionPathExists=/run/samba/smb.conf
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Samba configfile writer
|
|
||||||
After=samba-defaults.service
|
|
||||||
Requires=samba-defaults.service
|
|
||||||
|
|
||||||
ConditionPathExists=/storage/.cache/services/samba.conf
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/usr/lib/samba/samba-config
|
|
||||||
StartLimitInterval=0
|
|
@ -1,10 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Samba defaults
|
|
||||||
|
|
||||||
ConditionPathExists=!/storage/.cache/services/samba.conf
|
|
||||||
ConditionPathExists=!/storage/.cache/services/samba.disabled
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/bin/cp /usr/share/services/samba.conf /storage/.cache/services/
|
|
||||||
RemainAfterExit=yes
|
|
@ -1,16 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Samba SMB Daemon
|
Description=Samba SMB Daemon
|
||||||
After=network.target samba-config.service nmbd.service
|
After=network.target
|
||||||
Requires=samba-config.service
|
|
||||||
|
|
||||||
ConditionPathExists=/storage/.cache/services/samba.conf
|
|
||||||
ConditionPathExists=/run/samba/smb.conf
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/var/run/smbd-smb.conf.pid
|
PIDFile=/var/run/smbd-smb.conf.pid
|
||||||
LimitNOFILE=16384
|
LimitNOFILE=16384
|
||||||
ExecStart=/usr/bin/smbd --configfile=/run/samba/smb.conf
|
ExecStart=/usr/bin/smbd --configfile=/run/samba/smb.conf
|
||||||
|
ExecStartPre=/usr/lib/samba/samba-config
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
TimeoutStopSec=1s
|
TimeoutStopSec=1s
|
||||||
Restart=always
|
Restart=always
|
||||||
|
Loading…
x
Reference in New Issue
Block a user