| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | if [ "$(nvram get samba3_enable)" = "1" ]; then |
|---|
| 5 | |
|---|
| 6 | grep -q nobody /etc/passwd || echo "nobody:*:65534:65534:nobody:/var:/bin/false" >> /etc/passwd |
|---|
| 7 | |
|---|
| 8 | [ -d /var/samba ] || mkdir /var/samba |
|---|
| 9 | |
|---|
| 10 | touch /var/samba/smbpasswd |
|---|
| 11 | |
|---|
| 12 | USR1="$(nvram get samba3_usr1)" |
|---|
| 13 | PASS1="$(nvram get samba3_pass1)" |
|---|
| 14 | USR2="$(nvram get samba3_usr2)" |
|---|
| 15 | PASS2="$(nvram get samba3_pass2)" |
|---|
| 16 | |
|---|
| 17 | if [ "$(nvram get samba3_usr1)" != "" ]; then |
|---|
| 18 | grep -q $USR1 /etc/passwd || echo $USR1":*:1000:1000:"$USR1":/var:/bin/false" >> /etc/passwd |
|---|
| 19 | smbpasswd $USR1 $PASS1 |
|---|
| 20 | fi |
|---|
| 21 | |
|---|
| 22 | if [ "$(nvram get samba3_usr2)" != "" ]; then |
|---|
| 23 | grep -q $USR2 /etc/passwd || echo $USR2":*:1001:1001:"$USR2":/var:/bin/false" >> /etc/passwd |
|---|
| 24 | smbpasswd $USR2 $PASS2 |
|---|
| 25 | fi |
|---|
| 26 | |
|---|
| 27 | WORKGROUP="$(nvram get samba3_workgrp)" |
|---|
| 28 | SRVSTRING="$(nvram get samba3_srvstr)" |
|---|
| 29 | DIRPATH="$(nvram get samba3_dirpath)" |
|---|
| 30 | ACL="No" |
|---|
| 31 | |
|---|
| 32 | if [ "$(nvram get samba3_pubacl)" = "1" ]; then |
|---|
| 33 | ACL="Yes" |
|---|
| 34 | fi |
|---|
| 35 | |
|---|
| 36 | SMB_CONF=$( cat <<EOF |
|---|
| 37 | [global] |
|---|
| 38 | server string = $SRVSTRING |
|---|
| 39 | workgroup = $WORKGROUP |
|---|
| 40 | interfaces = br* |
|---|
| 41 | bind interfaces only = Yes |
|---|
| 42 | map to guest = Bad User |
|---|
| 43 | smb passwd file = /var/samba/smbpasswd |
|---|
| 44 | private dir = /var/samba |
|---|
| 45 | passdb backend = smbpasswd |
|---|
| 46 | log file = /var/smbd.log |
|---|
| 47 | max log size = 1000 |
|---|
| 48 | socket options = TCP_NODELAY |
|---|
| 49 | printing = none |
|---|
| 50 | load printers = No |
|---|
| 51 | usershare allow guests = Yes |
|---|
| 52 | EOF |
|---|
| 53 | ) |
|---|
| 54 | |
|---|
| 55 | PUBLIC=$( cat <<EOF |
|---|
| 56 | |
|---|
| 57 | [Public] |
|---|
| 58 | comment = Public Share |
|---|
| 59 | path = $DIRPATH |
|---|
| 60 | read only = $ACL |
|---|
| 61 | guest ok = Yes |
|---|
| 62 | force user = root |
|---|
| 63 | EOF |
|---|
| 64 | ) |
|---|
| 65 | |
|---|
| 66 | SMB_CONF_CUSTOM="$(nvram get samba3_conf)" |
|---|
| 67 | |
|---|
| 68 | if [ "$(nvram get samba3_conf)" != "" ] && [ "$(nvram get samba3_advanced)" = "1" ]; then |
|---|
| 69 | echo "$SMB_CONF_CUSTOM" > /tmp/smb.conf |
|---|
| 70 | if [ "$(nvram get samba3_pub)" = "1" ]; then |
|---|
| 71 | echo "$PUBLIC" >> /tmp/smb.conf |
|---|
| 72 | fi |
|---|
| 73 | else |
|---|
| 74 | echo "$SMB_CONF" > /tmp/smb.conf |
|---|
| 75 | echo "$PUBLIC" >> /tmp/smb.conf |
|---|
| 76 | fi |
|---|
| 77 | chmod 777 /jffs |
|---|
| 78 | |
|---|
| 79 | /usr/sbin/nmbd -D --configfile=/tmp/smb.conf |
|---|
| 80 | /usr/sbin/smbd -D --configfile=/tmp/smb.conf |
|---|
| 81 | |
|---|
| 82 | fi |
|---|
| 83 | |
|---|
| 84 | |
|---|