source: src/router/samba3/config/samba3.startup @ 15222

Last change on this file since 15222 was 15222, checked in by eko, 3 years ago

some samba3 improvements

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