Advertisement
overloop

create_samba_share.sh

Oct 20th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. #!/bin/bash
  2. if [ $# -lt 2 ]; then
  3. echo "pass share dir and share name"
  4. exit -1
  5. fi
  6.  
  7. i=$( whoami )
  8. if [ "$i" != "root" ]; then
  9. echo "you need to be root to run this script"
  10. exit -1
  11. fi
  12.  
  13. share_dir=$1
  14. share_name=$2
  15.  
  16. if [ ! -d $share_dir ]; then
  17. mkdir $share_dir
  18. fi
  19.  
  20. echo -e "[$share_name]\nwritable = yes\npath = $share_dir\nguest ok = yes\nforce group = nogroup\nforce user = nobody\n" >> /etc/samba/smb.conf
  21.  
  22. chown nobody:nogroup $share_dir
  23. chmod a+rwx $share_dir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement