3 BETCDIR='/etc/mcollective'
4 BRUBYDIR='/Library/Ruby/Site/1.8'
7 BLIBEXECDIR='/usr/libexec/mcollective'
8 BDOCDIR='/usr/share/doc/mcollective'
9 BLAUNCHDIR='/Library/LaunchDaemons'
10 BLOGDIR='/var/log/mcollective'
11 PACKAGEMAKER='/Applications/PackageMaker.app/Contents/MacOS/PackageMaker'
13 if [ -z $MPATH ]; then
14 echo 'Please give the path to the MCollective source directory'
19 echo "It is recommended to install stomp on this system using ruby gems"
24 echo 'It is required to have the latest XCode installed'
28 # Make sure we have stomp so we can load mcollective
29 /usr/bin/ruby <<EOF || msg_stomp
34 # Make sure we have PackageMaker installed
35 [ -x $PACKAGEMAKER ] || msg_xcode
37 # Get the MCollective version
38 export RUBYLIB=$RUBYLIB:$MPATH/lib
39 mcversion=$(/usr/bin/ruby <<EOF
41 puts MCollective.version
45 # Make our tmp directory
47 common_tmpdir=`mktemp -d /tmp/${tmpbase}-common_$mcversion.XXXX` || exit 1
48 client_tmpdir=`mktemp -d /tmp/${tmpbase}-client_$mcversion.XXXX` || exit 1
49 tmpdir=`mktemp -d /tmp/${tmpbase}_$mcversion.XXXX` || exit 1
50 pkgdir=`mktemp -d /tmp/${tmpbase}_${mcversion}_packages.XXXX` || exit 1
52 # Build the common environment
53 mkdir -p "$common_tmpdir/$BRUBYDIR"
54 mkdir -p "$common_tmpdir/$BLIBEXECDIR"
55 mkdir -p "$common_tmpdir/$BDOCDIR"
56 mkdir -p "$common_tmpdir/$BLOGDIR"
58 cp -r $MPATH/lib/mcollective $common_tmpdir/$BRUBYDIR/
59 cp $MPATH/lib/mcollective.rb $common_tmpdir/$BRUBYDIR/
60 cp -r $MPATH/plugins/mcollective $common_tmpdir/$BLIBEXECDIR/
61 cp $MPATH/COPYING $common_tmpdir/$BDOCDIR/
63 # Build the server environment
64 mkdir -p "$tmpdir/$BSBINDIR"
65 mkdir -p "$tmpdir/$BETCDIR"
66 mkdir -p "$tmpdir/$BETCDIR/ssl/clients"
67 mkdir -p "$tmpdir/$BLAUNCHDIR"
69 cp $MPATH/bin/mcollectived $tmpdir/$BSBINDIR/mcollectived
70 cp $MPATH/etc/facts.yaml.dist $tmpdir/$BETCDIR/facts.yaml
71 cp $MPATH/etc/server.cfg.dist $tmpdir/$BETCDIR/server.cfg
73 # This is needed for macs since launcd will handle daemonizing
74 perl -i -pe 's/daemonize = 1/daemonize = 0/' $tmpdir/$BETCDIR/server.cfg
76 # Build the client environment
77 mkdir -p "$client_tmpdir/$BETCDIR"
78 mkdir -p "$client_tmpdir/$BSBINDIR"
80 cp $MPATH/etc/client.cfg.dist $client_tmpdir/$BETCDIR/client.cfg
81 cp $MPATH/etc/rpc-help.erb $client_tmpdir/$BETCDIR/
82 cp $MPATH/bin/mc-call-agent $client_tmpdir/$BSBINDIR/
83 cp $MPATH/bin/mco $client_tmpdir/$BSBINDIR/
85 #Build our launchd property list file
86 cat - > $tmpdir/$BLAUNCHDIR/org.marionette-collective.mcollective.plist <<EOF
87 <?xml version="1.0" encoding="UTF-8"?>
88 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
91 <key>EnvironmentVariables</key>
94 <string>/sbin:/usr/sbin:/bin:/usr/bin</string>
96 <string>/Library/Ruby/Site/1.8</string>
99 <string>org.marionette-collective.mcollective</string>
104 <key>ProgramArguments</key>
106 <string>/usr/sbin/mcollectived</string>
107 <string>--config=/etc/mcollective/server.cfg</string>
111 <key>ServiceDescription</key>
112 <string>MCollective Server</string>
113 <key>ServiceIPC</key>
120 #Make our Packages. This requires XCode be installed
121 $PACKAGEMAKER -r $tmpdir --version $mcversion --title "MCollective" -l / -o $pkgdir/MCollective_$mcversion.pkg -i org.marionette-collective.mcollective
122 $PACKAGEMAKER -r $common_tmpdir --version $mcversion --title "MCollective Common" -l / -o $pkgdir/MCollective-Common_$mcversion.pkg -i org.marionette-collective.mcollective-common
123 $PACKAGEMAKER -r $client_tmpdir --version $mcversion --title "MCollective Client" -l / -o $pkgdir/MCollective-Client_$mcversion.pkg -i org.marionette-collective.mcollective-client
125 # Make sure that we install the stomp gem, this is ugly and should be part of the package
126 cat - > $pkgdir/MCollective-Common_$mcversion.pkg/Contents/Resources/postflight <<EOF
128 /usr/bin/gem install --no-ri --no-rdoc stomp
130 chmod +x $pkgdir/MCollective-Common_$mcversion.pkg/Contents/Resources/postflight
132 # launchd complains if the permissions aren't right, this is a dumb hack that
133 # I needed since PackageMaker doesn't seem to respect permissions (originally had chmod 644 in the tmpdir)
134 cat - > $pkgdir/MCollective_$mcversion.pkg/Contents/Resources/postflight <<EOF
136 chmod 644 /Library/LaunchDaemons/org.marionette-collective.mcollective.plist
138 chmod +x $pkgdir/MCollective_$mcversion.pkg/Contents/Resources/postflight
140 # Create a r/o compressed dmg from our pkgs
141 hdiutil create -srcfolder $pkgdir -format UDZO -scrub -imagekey zlib-level=9 -volname "mcollective-$mcversion" mcollective-$mcversion.dmg
145 rm -rf $common_tmpdir
146 rm -rf $client_tmpdir