Skip to content

Commit

Permalink
Beats preference pane for macOS (#6923)
Browse files Browse the repository at this point in the history
* Beats preference pane for macOS

This preference pane shows up in System Preferences and allows to manage
installed beats.

* Generate installable package for preference pane

Added a make target to generate a package (.pkg) file that can be
installed or bundled along another installer. It can be optionally
signed for distribution.

* Capitalize beat name in the UI

* Update license headers

Added new Elastic license boilerplate plus some missing headers.

* Fix code-signing when no dev certificate present

Makes build to work when no internal developer certificate has been
created in XCode.
  • Loading branch information
adriansr authored and andrewkroh committed May 31, 2018
1 parent 2b0df2f commit fe23344
Show file tree
Hide file tree
Showing 30 changed files with 2,492 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dev-tools/packer/platforms/darwin/preference-pane/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PROJECT=beats-preference-pane.xcodeproj
CONFIGURATION?=Release
SIGN_IDENTITY_APP?=
SIGN_IDENTITY_INSTALLER?=
PACKAGE_NAME?=BeatsPrefPane.pkg
INSTALL_DIR=/Library/PreferencePanes
IDENTIFIER?=co.elastic.beats.preference-pane
VERSION?=1.0.0

default: build

build:
xcodebuild build -project $(PROJECT) -alltargets -configuration $(CONFIGURATION) CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
echo version="${VERSION}"
test -n '$(SIGN_IDENTITY_APP)' && \
codesign -s '$(SIGN_IDENTITY_APP)' --force --keychain '$(KEYCHAIN)' --timestamp \
build/$(CONFIGURATION)/*.prefPane/Contents/MacOS/helper && \
codesign -s '$(SIGN_IDENTITY_APP)' --force --keychain '$(KEYCHAIN)' --timestamp \
build/$(CONFIGURATION)/*.prefPane

.PHONY: clean pkg

pkg: $(PACKAGE_NAME)

$(PACKAGE_NAME): build
mkdir -p build/root/$(INSTALL_DIR)
cp -a build/$(CONFIGURATION)/Beats.prefPane build/root/$(INSTALL_DIR)/
SIGN_ARGS='' ;\
test -z '$(SIGN_IDENTITY_INSTALLER)' || SIGN_ARGS="--sign $(SIGN_IDENTITY_INSTALLER)" ;\
pkgbuild --root build/root/ \
--identifier $(IDENTIFIER) \
--version '$(VERSION)' \
$$SIGN_ARGS --keychain "$(KEYCHAIN)" --timestamp \
$(PACKAGE_NAME)

clean:
rm -rf build/ $(PACKAGE_NAME)

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>FILEHEADER</key>
<string><![CDATA[
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.]]></string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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>SchemeUserState</key>
<dict>
<key>beats-preference-pane.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>helper.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>launchctl-helper.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>3A6F9AB1202C939D0046F40E</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

@protocol AuthorizationProvider
- (BOOL) isUnlocked;
- (BOOL) forceUnlock;
- (int) runAsRoot:(NSString*) program args:(NSArray*)args;
- (int) runHelperAsRootWithArgs:(NSArray*)args;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="BeatViewController">
<connections>
<outlet property="bootButton" destination="MjM-JV-S7c" id="75Y-PL-oLn"/>
<outlet property="bootLabel" destination="AAN-SQ-TFH" id="sCr-QF-pjb"/>
<outlet property="configField" destination="O6N-J7-p3I" id="Z6e-cb-PSL"/>
<outlet property="editButton" destination="ItH-wj-0Cw" id="WRI-a4-SSz"/>
<outlet property="logsButton" destination="wjS-qN-bak" id="033-Lg-qOx"/>
<outlet property="logsField" destination="jYM-AQ-ln1" id="xyL-By-T16"/>
<outlet property="startStopButton" destination="UmY-rv-hlt" id="x2n-XH-W1F"/>
<outlet property="statusLabel" destination="P8r-yk-VlO" id="twY-BN-vmW"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="622" height="250"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="P8r-yk-VlO">
<rect key="frame" x="18" y="213" width="509" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="somebeat is running with PID NNN" id="iBY-Kv-1K8">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AAN-SQ-TFH">
<rect key="frame" x="18" y="188" width="509" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Start at boot:" id="5ti-tm-ylo">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UmY-rv-hlt">
<rect key="frame" x="527" y="202" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="_" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="MeS-id-OHJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="startStopTapped:" target="-2" id="aUi-Ca-fOB"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MjM-JV-S7c">
<rect key="frame" x="527" y="177" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Toggle" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rAu-9w-26G">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="startAtBootTapped:" target="-2" id="bfi-QP-4Ns"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mgf-md-dqZ">
<rect key="frame" x="20" y="163" width="499" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Configuration file:" id="H0M-hK-Yi8">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nEi-OQ-sX1">
<rect key="frame" x="20" y="108" width="499" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Logs directory:" id="tOf-qp-aa2">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="O6N-J7-p3I">
<rect key="frame" x="20" y="133" width="497" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="/etc/somebeat/somebeat.yml" drawsBackground="YES" id="o6P-ER-dfr">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlHighlightColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jYM-AQ-ln1">
<rect key="frame" x="20" y="78" width="497" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="/var/log/somebeat" drawsBackground="YES" id="PDw-PN-E2m">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlHighlightColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ItH-wj-0Cw">
<rect key="frame" x="527" y="126" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jAq-Qt-XLO">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="editConfigTapped:" target="-2" id="S66-lr-DaJ"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wjS-qN-bak">
<rect key="frame" x="527" y="72" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="View" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="7eK-sI-JKe">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="viewLogsTapped:" target="-2" id="2xJ-ye-Iqo"/>
</connections>
</button>
</subviews>
</customView>
</objects>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="BeatsPrefPane">
<connections>
<outlet property="_window" destination="F0z-JX-Cv5" id="NnN-bg-bZB"/>
<outlet property="authView" destination="jRa-yp-9Xb" id="MtY-bg-bZB"/>
<outlet property="beatsTab" destination="FM1-Fe-4cx" id="6By-9p-HRh"/>
<outlet property="messageLabel" destination="tOg-IC-8mc" id="pbr-u1-RiH"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="≪ do not localize ≫" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" deferred="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5" userLabel="PrefPane">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="120" y="952" width="668" height="368"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="668" height="368"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tabView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FM1-Fe-4cx">
<rect key="frame" x="13" y="58" width="642" height="296"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="Tab" identifier="" id="VJt-jx-ETg">
<view key="view" ambiguous="YES" id="5eb-hd-Ob6">
<rect key="frame" x="10" y="33" width="622" height="250"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="View" identifier="" id="vXA-Bh-dnF">
<view key="view" id="Qvi-4Z-nmr">
<rect key="frame" x="10" y="33" width="622" height="250"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
</tabViewItems>
</tabView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jRa-yp-9Xb" customClass="SFAuthorizationView">
<rect key="frame" x="20" y="20" width="628" height="40"/>
<autoresizingMask key="autoresizingMask"/>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tOg-IC-8mc">
<rect key="frame" x="18" y="138" width="632" height="91"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="No beats found." allowsEditingTextAttributes="YES" id="Um2-mR-CDT">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<point key="canvasLocation" x="30" y="271"/>
</window>
<userDefaultsController representsSharedInstance="YES" id="BOZ-Dv-ddx"/>
</objects>
</document>
Loading

0 comments on commit fe23344

Please sign in to comment.