-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
91 lines (73 loc) · 2.45 KB
/
install.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
#############################################
#
# Quickstart Agent Installer
# Author: Stephen Hynes
# Version: 1.0
#
#############################################
# Need root to run this script
if [ "$(id -u)" != "0" ]; then
echo "Please run this script as root."
echo "Usage: sudo ./install.sh"
exit 1
fi
TMP_DIR=$(mktemp -d -t logentries.XXXXX)
trap "rm -rf "$TMP_DIR"" EXIT
FILES="le.py backports.py utils.py __init__.py metrics.py formatters.py"
LE_PARENT="https://raw.githubusercontent.com/logentries/le/master/src/"
CURL="/usr/bin/env curl -O"
INSTALL_DIR="/usr/share/logentries"
LOGGER_CMD="logger -t LogentriesTest Test Message Sent By LogentriesAgent"
DAEMON="com.logentries.agent.plist"
DAEMON_DL_LOC="https://raw.githubusercontent.com/logentries/le/master/install/mac/$DAEMON"
DAEMON_PATH="/Library/LaunchDaemons/"
INSTALL_PATH="/usr/bin/le"
REGISTER_CMD="$INSTALL_PATH register"
LE_FOLLOW="$INSTALL_PATH follow"
printf "Welcome to the Logentries Install Script\n"
printf "Downloading dependencies...\n"
cd "$TMP_DIR"
for file in $FILES ; do
$CURL $LE_PARENT/$file
done
$CURL $DAEMON_DL_LOC
sed -i -e 's/python2/python/' *.py
printf "Copying files...\n"
mkdir -p "$INSTALL_DIR"/logentries || true
mv *.py "$INSTALL_DIR"/logentries
chown -R root:wheel "$INSTALL_DIR"
chmod +x "$INSTALL_DIR"/logentries/le.py
chown root:wheel $DAEMON
mv $DAEMON $DAEMON_PATH
rm -f "$INSTALL_PATH" || true
ln -s "$INSTALL_DIR"/logentries/le.py "$INSTALL_PATH" 2>/dev/null || true
$REGISTER_CMD
$LE_FOLLOW "/var/log/system.log"
printf "\n**** Install Complete! ****\n\n"
printf "If you would like to monitor more files, simply run this command as root, 'le follow filepath', e.g. 'le follow /var/log/mylog.log'\n\n"
printf "And be sure to restart the agent service for new files to take effect, you can do this with the following two commands.\n"
printf "launchctl unload ${DAEMON_PATH}\n"
printf "launchctl load ${DAEMON_PATH}\n"
printf "For a full list of commands, run 'le --help' in the terminal.\n\n"
launchctl unload $DAEMON_PATH$DAEMON
launchctl load $DAEMON_PATH$DAEMON
printf "Starting agent"
i="0"
while [ $i -lt 40 ]
do
sleep 0.05
printf "."
i=$[$i+1]
done
printf "DONE\n\nWe will now send some sample events to your new Logentries account. This will take about 10 seconds.\n\n"
l=1
while [ $l -le 100 ]
do
logger "Logentries Test Event ${l}"
printf "."
sleep 0.1
l=$(( $l + 1 ))
done
printf "DONE\n"
exit 0