diff --git a/INSTALL b/INSTALL index 6e0e6e77..e26a35b5 100644 --- a/INSTALL +++ b/INSTALL @@ -19,7 +19,18 @@ MacOSX: * install homebrew (https://github.com/mxcl/homebrew) * export ARCHFLAGS="-arch x86_64" * brew install pkg-config libao + * make * perl -MCPAN -e 'install Crypt::OpenSSL::RSA' + * perl -MCPAN -e 'install IO::Socket::INET6' + * perl shairport.pl OSX 10.5 only bundles perl 5.8, which won't work with shairport. After getting a update here (http://www.perl.org/get.html), it worked. + +How to run as a daemon on Mac 10.6 +------ +* cp hairtunes shairport.pl /usr/local/bin +* vi /usr/local/bin/shairport.pl, change the path of hairtunes from ./hairtunes to /usr/local/bin/hairtunes +* cp org.mafipulation.shairport.plist ~/Library/LaunchAgents/ +* launchctl load org.mafipulation.shairport.plist +* launchctl unload org.mafipulation.shairport.plist (to remove) diff --git a/README b/README index f1a5e1b5..9214120d 100644 --- a/README +++ b/README @@ -34,4 +34,3 @@ Changelog 0.03 April 11, 2011 bugfix: ipv6 didn't work - IO::Socket::INET6 is required too - diff --git a/org.mafipulation.shairport.plist b/org.mafipulation.shairport.plist new file mode 100644 index 00000000..9c6530a1 --- /dev/null +++ b/org.mafipulation.shairport.plist @@ -0,0 +1,16 @@ + + + + + Label + org.mafipulation.shairport + RunAtLoad + + ProgramArguments + + /usr/local/bin/shairport.pl + --apname + RJ + + + diff --git a/shairport.pl b/shairport.pl index 63c29e32..543322cb 100755 --- a/shairport.pl +++ b/shairport.pl @@ -1,18 +1,5 @@ #!/usr/bin/perl -# Configure the following two options: -# AP name - as will be shown in iTunes' menu -# example: -# my $apname = "SteePort"; -my $apname = "ShairPort $$ on " . `hostname`; - -# password - required to connect -# for no password, set: -# my $password = ''; -my $password = ''; - -# that's all! - # ShairPort - Airtunes compatible server # Copyright (c) 2011 James Laird # All rights reserved. @@ -36,6 +23,9 @@ my $password = ''; # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. +use Getopt::Long; +use FindBin; + use IO::Select; use IO::Socket; use MIME::Base64; @@ -47,6 +37,24 @@ use Digest::MD5 qw/md5_hex/; use POSIX ":sys_wait_h"; eval "use IO::Socket::INET6;"; + +# Configure the following two options: +# AP name - as will be shown in iTunes' menu +# example: +# my $apname = "SteePort"; + +my $apname = "ShairPort $$ on " . `hostname`; +# password - required to connect +# for no password, set: +my $password = ''; +# suppose hairtunes is under same directory +my $hairtunes_cli = $FindBin::Bin . '/hairtunes'; + +GetOptions("apname=s" => \$apname, + "password=s" => \$password); + +# use --apname MyName --password secret as arguments + chomp $apname; my @hw_addr = (0, map { int rand 256 } 1..5); @@ -72,7 +80,7 @@ if ($avahi_publish==0) { "5000", "tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1"; die "could not run avahi-publish-service nor dns-sd"; -} +} sub REAP { if ($avahi_publish == waitpid(-1, WNOHANG)) { @@ -282,7 +290,7 @@ sub conn_handle_request { $resp->header('Session', 'DEADBEEF'); - my $dec = sprintf("./hairtunes iv %s key %s fmtp %s cport %s tport %s dport %s host %s", + my $dec = sprintf("$hairtunes_cli iv %s key %s fmtp %s cport %s tport %s dport %s host %s", map { "'$_'" } ( unpack('H*', $conn->{aesiv}), unpack('H*', $conn->{aeskey}),