Skip to content

Instantly share code, notes, and snippets.

@maddox
Created February 29, 2012 06:37
Show Gist options
  • Save maddox/1938575 to your computer and use it in GitHub Desktop.
Save maddox/1938575 to your computer and use it in GitHub Desktop.
Install script for Samba3

Install Samba 3 on OS X 10.7 Lion

Run the two commands below one at a time to get Samba 3 installed and to have it run on boot.

Install Samba with Homebrew

sh < <(curl https://raw.github.com/gist/1938575/df254d9a2ac83dddb04fcc7f9b634b65708aa477/

Set Samba up to launch on boot

sudo sh < <(curl -s https://raw.github.com/gist/1938575/3eef666a05bffb215e34d54f0e25599a187cc7a6/install.sh)
#!/usr/bin/env bash
# disable system netbiosd-Daemon
sudo launchctl stop com.apple.netbiosd
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.netbiosd.plist
# create dirs that need to be there
mkdir /usr/local/Cellar/samba/3.6.3/var/locks
mkdir /usr/local/Cellar/samba/3.6.3/private
sudo smbpasswd -a `whoami`
# install new samba into launchd
sudo curl https://raw.github.com/gist/1938575/e9310a0cc981555a4d6cfed4c93a2d2ef1f04883/org.samba.smbd.plist >> /Library/LaunchAgents/org.samba.smbd.plist
sudo launchctl load -w /Library/LaunchAgents/org.samba.smbd.plist
# install new netbios into launchd
sudo curl https://raw.github.com/gist/1938575/b6c1c3d80c7a72895dbc8a5e4e03d63368c87c4f/org.samba.nmbd.plist >> /Library/LaunchAgents/org.samba.nmbd.plist
sudo launchctl load -w /Library/LaunchAgents/org.samba.nmbd.plist
#!/usr/bin/env bash
# https://github.com/mxcl/homebrew/pull/10311
# install samba
brew install https://raw.github.com/vertis/homebrew/e98536748ec8214bf0a527cf5515092140fc4b95/Library/Formula/samba.rb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.samba.nmbd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/samba/3.6.3/sbin/nmbd</string>
<string>-D</string>
</array>
<key>OnDemand</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ServiceDescription</key>
<string>netbios</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.samba.smbd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/samba/3.6.3/sbin/smbd</string>
<string>-D</string>
</array>
<key>OnDemand</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ServiceDescription</key>
<string>samba</string>
</dict>
</plist>
@eduo
Copy link

eduo commented Dec 1, 2012

It should. Launchd doesn't allow daemons so this would fail more often than work. -F is the way to go.

Optionally, a single launchd could have both smbd and nmbd and a second launchd could restart both when smb.conf is modified (similar to how Apple's installation worked)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment