From 3e54bdda5be522136c8291cc3afa0ac633216d4e Mon Sep 17 00:00:00 2001 From: Stefan Saraev Date: Wed, 18 Dec 2013 00:02:06 +0200 Subject: [PATCH] samba: external drives autoshare --- packages/network/samba/package.mk | 1 + .../network/samba/scripts/samba-autoshare | 29 +++++++++++++++++++ packages/network/samba/scripts/samba-config | 10 +++++++ 3 files changed, 40 insertions(+) create mode 100755 packages/network/samba/scripts/samba-autoshare diff --git a/packages/network/samba/package.mk b/packages/network/samba/package.mk index 8dd053433d..cae221e215 100644 --- a/packages/network/samba/package.mk +++ b/packages/network/samba/package.mk @@ -181,6 +181,7 @@ makeinstall_target() { mkdir -p $INSTALL/usr/lib/samba cp $PKG_DIR/scripts/samba-config $INSTALL/usr/lib/samba + cp $PKG_DIR/scripts/samba-autoshare $INSTALL/usr/lib/samba if [ -f $PROJECT_DIR/$PROJECT/config/smb.conf ]; then mkdir -p $INSTALL/etc/samba diff --git a/packages/network/samba/scripts/samba-autoshare b/packages/network/samba/scripts/samba-autoshare new file mode 100755 index 0000000000..4bc78b60b8 --- /dev/null +++ b/packages/network/samba/scripts/samba-autoshare @@ -0,0 +1,29 @@ +#!/bin/sh +################################################################################ +# This file is part of OpenELEC - http://www.openelec.tv +# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenELEC.tv; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA. +# http://www.gnu.org/copyleft/gpl.html +################################################################################ + +if [ -f /storage/.cache/services/samba.conf ]; then + . /storage/.cache/services/samba.conf + + if [ "$SAMBA_AUTOSHARE" == "true" ] ; then + systemctl restart samba-config.service + systemctl restart smbd.service + fi +fi diff --git a/packages/network/samba/scripts/samba-config b/packages/network/samba/scripts/samba-config index 914e9a134e..2f4ad9e3a5 100755 --- a/packages/network/samba/scripts/samba-config +++ b/packages/network/samba/scripts/samba-config @@ -33,6 +33,16 @@ if [ -f /storage/.cache/services/samba.conf ]; then cp $SMB_DEFCONF $SMB_CONF fi + # handle external drives + if [ "$SAMBA_AUTOSHARE" == "true" ] ; then + for dir in /media/* ; do + if [ -d "$dir" ] ; then + name=$(basename "$dir") + echo -e "[$name]\n path = $dir\n available = yes\n browsable = yes\n public = yes\n writable = yes\n" >> $SMB_CONF + fi + done + fi + # 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;"`