-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[osx] Log to file pre/postinstall scripts
- set rights to current user - launch the app at the end of the install - doesn't install if smae version and already installed
- Loading branch information
Showing
2 changed files
with
56 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
#!/bin/sh | ||
|
||
INSTALL_DIR=/opt/datadog-agent | ||
LOG_DIR=/var/log/datadog | ||
APP_CONF_DIR="/Applications/Datadog Agent.app/Contents/Resources" | ||
|
||
# We log stdout & stderr of this script | ||
LOG_FILE=$LOG_DIR/preinstall.log | ||
mkdir -p $LOG_DIR | ||
exec > $LOG_FILE 2>&1 | ||
|
||
# OS/Distro Detection | ||
DISTRIBUTION=$(grep -Eo "(Debian|Ubuntu|RedHat|CentOS|openSUSE|Amazon)" /etc/issue 2>/dev/null || uname -s) | ||
|
||
|
||
if [ $DISTRIBUTION = "Darwin" ]; then | ||
if [ -e "$APP_CONF_DIR/datadog.conf" ]; then | ||
# Stop old version | ||
"$APP_CONF_DIR/../MacOS/datadog-agent" stop || true | ||
osascript -e 'quit app "Datadog Agent"' || true | ||
|
||
# Save old conf | ||
cp -f "$APP_CONF_DIR/datadog.conf" /tmp | ||
cp -fR "$APP_CONF_DIR/checks.d" /tmp | ||
cp -fR "$APP_CONF_DIR/conf.d" /tmp | ||
fi | ||
|
||
# Clean before install | ||
rm -rf $INSTALL_DIR | ||
fi | ||
exit 0 |