-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_macos.sh
executable file
·38 lines (29 loc) · 1.16 KB
/
install_macos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -euo pipefail
INSTALL_DIR=/usr/local/opt/docker-lifecycle-listener
BINARY_DIR="$INSTALL_DIR/sbin/"
BINARY=docker-lifecycle-listener.sh
sudo rm -rf "$INSTALL_DIR"
mkdir -p "$BINARY_DIR"
cp "$BINARY" "$BINARY_DIR"
chmod u=rx,g=rx,o=rx "$BINARY_DIR/$BINARY"
SCRIPT_DIR=/usr/local/etc/docker-lifecycle-listener.d
mkdir -p "$SCRIPT_DIR/on_start"
mkdir -p "$SCRIPT_DIR/on_stop"
sudo chmod -R u=rwx,g=rx,o=rx "$SCRIPT_DIR"
sudo chown -R root:wheel "$SCRIPT_DIR"
LISTENER_SERVICE_NAME=uk.org.lidalia.docker-lifecycle-listener
LISTENER_SERVICE_FILE_NAME="$LISTENER_SERVICE_NAME.plist"
LISTENER_SERVICE_LOCATION="/Library/LaunchDaemons/$LISTENER_SERVICE_FILE_NAME"
if launchctl list | grep $LISTENER_SERVICE_NAME; then
echo "Unloading $LISTENER_SERVICE_LOCATION"
sudo launchctl unload "$LISTENER_SERVICE_LOCATION"
echo "Unloaded $LISTENER_SERVICE_LOCATION"
fi
sudo cp "$LISTENER_SERVICE_FILE_NAME" "$LISTENER_SERVICE_LOCATION"
echo "Loading $LISTENER_SERVICE_LOCATION"
sudo launchctl load "$LISTENER_SERVICE_LOCATION"
echo "Loaded $LISTENER_SERVICE_LOCATION"
sudo launchctl start $LISTENER_SERVICE_NAME
echo "Started $LISTENER_SERVICE_NAME"
./install_notifier.sh