Changeset 4433

Show
Ignore:
Timestamp:
08.03.2010 22:21:00 (5 months ago)
Author:
er13
Message:

samba_conf:

  • avoid using bash-specific operators
  • various minor cleanups, fixes & indentation changes
  • fixes #670
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/make/samba/files/root/etc/default.samba/samba_conf

    r4404 r4433  
    11#!/bin/sh 
    22 
    3 CFGCTL=`which usbcfgctl` 
     3CFGCTL="$(which usbcfgctl)" 
    44[ -z "$CFGCTL" ] && CFGCTL=ar7cfgctl 
    55 
     
    3838echo "### default" 
    3939 
    40 if [ "`echo usbhost.samba_server_enabled | $CFGCTL -s`" = "yes" ]; then 
    41 #if [ "$SAMBA_DEFAULT_SHARE" = "yes" ]; then 
    42         for SHARE in /var/media/ftp/* ; do 
    43           if test -d $SHARE ; then 
    44                 SHORTNAME=`basename $SHARE | sed s/-Partition-/-/` 
    45                 echo "[$SHORTNAME]" 
    46                 echo " path = $SHARE" 
    47                 echo " user = ftpuser" 
     40if [ "$(echo usbhost.samba_server_enabled | $CFGCTL -s)" = "yes" ]; then 
     41        for SHARE in /var/media/ftp/*; do 
     42                if [ -d "$SHARE" ]; then 
     43                        SHORTNAME="$(basename "$SHARE" | sed s/-Partition-/-/)" 
     44                        echo "[$SHORTNAME]" 
     45                        echo " path = $SHARE" 
     46                        echo " user = ftpuser" 
    4847 
    49                 if [ "$(echo usbhost.readonly | $CFGCTL -s)" != "yes" ] ; then   
    50                         echo " read only = no" 
    51                 else 
    52                         echo " read only = yes" 
     48                        if [ "$(echo usbhost.readonly | $CFGCTL -s)" = "yes" ]; then 
     49                                echo " read only = yes" 
     50                        else 
     51                                echo " read only = no" 
     52                        fi 
     53 
     54                        if [ "$(echo usbhost.password | $CFGCTL -s)" = "\"\"" ]; then 
     55                                echo " guest ok = yes" 
     56                        fi 
     57 
     58                        echo " write cache size = 65536" 
    5359                fi 
    54  
    55                 if [ "$(echo usbhost.password | $CFGCTL -s)" = "\"\"" ] ; then 
    56                         echo " guest ok = yes" 
    57                 fi 
    58  
    59                 echo " write cache size = 65536" 
    60         fi 
    6160        done 
    6261fi 
     
    7675                        esac 
    7776                        if  [ "$options" != "-" ]; then 
    78                                 options=${options//\%20/ } 
    79                                 options=${options//=/ = } 
     77                                options="$(echo "$options" | sed -r -e 's,=, = ,g;s,(%20| )+, ,g;')" 
    8078                        else 
    8179                                options="" 
    8280                        fi 
    83                         if [[ ! $options =~ "user =" ]]; then 
    84                                 options="$options,user = ftpuser" 
    85                         fi 
    86                         if [[ ! $options =~ "write cache size =" ]]; then 
    87                                 options="$options,write cache size = 65536" 
    88                         fi 
    89                         options=$(echo -e ${options//,/\\n }) 
     81                        echo "$options" | grep -q "user =" >/dev/null 2>&1 || options="$options,user = ftpuser" 
     82                        echo "$options" | grep -q "write cache size =" >/dev/null 2>&1 || options="$options,write cache size = 65536" 
     83                        options="$(echo -e "${options//,/\\n }")" 
    9084cat << EOF 
    91 [${name/%20/ }] 
     85[${name//%20/ }] 
    9286 comment = $comment 
    9387 path = $path 
     
    10195 
    10296echo "### fin" 
    103