Skip to content

Instantly share code, notes, and snippets.

@designer2k2
Last active January 5, 2019 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designer2k2/cdaf6b472975516c0b4d496d9755f19d to your computer and use it in GitHub Desktop.
Save designer2k2/cdaf6b472975516c0b4d496d9755f19d to your computer and use it in GitHub Desktop.
Install samba on a Raspberry Pi with sharing root config
#!/bin/sh
#this bash script installs samba sharing / and gives it to the pi user
apt-get update # To get the latest package lists
apt-get install samba samba-common-bin -y
#set pi password:
(echo raspberry; echo raspberry) | smbpasswd -a pi
#restart samba to ensure config is present
service smbd restart
service nmbd restart
#check if config is already ok:
if grep -q "\[root\]" /etc/samba/smb.conf;
then
echo smb.conf already found
else
echo add block to smb.conf
echo -e "[root]\n comment=root\n path=/\n browsable=yes\n writeable=yes\n valid users=pi\n only guest=no" >> /etc/samba/smb.conf
echo -e " create mask=07777\n directory mask=07777\n public = no\n force user = root" >> /etc/samba/smb.conf
fi
#restart samba:
service smbd restart
service nmbd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment