-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathconfigure_samba
executable file
·33 lines (29 loc) · 973 Bytes
/
configure_samba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Set up Samba the way I (Matthias) have it set up on my systems.
# must run using sudo. Also run "install-packages-extra" first to install samba.
#
# After running this script on the pi, assuming pi is at 192.168.0.106,
# use the following this this command from the windows shell
# to map the /home/pi directory to the drive letter X
#
# net use x: \\192.168.0.106\pi /user:pi mine
if [ -z "$1" ]; then
# Samba user name was passed as argument
user=pi
else
# Default to pi for user if no argument
user=$1
fi
echo "configuring samba for user: $user"
if [ "$EUID" -ne 0 ]; then
echo "Must run this as root"
exit
fi
echo "[$user]" >> /etc/samba/smb.conf
echo "path = /home/$user" >> /etc/samba/smb.conf
echo "valid users = $user" >> /etc/samba/smb.conf
echo "browsable = yes" >> /etc/samba/smb.conf
echo "read only = no" >> /etc/samba/smb.conf
# Set samba password
printf "mine\nmine" | smbpasswd -s -a $user
service smbd restart