aboutsummaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorRenato Golin <rengolin@gmail.com>2016-06-06 15:08:49 +0100
committerRenato Golin <rengolin@gmail.com>2016-06-06 15:51:14 +0100
commit188efc58336c1f953954958122276aebafa745de (patch)
tree8437961d6a00501aa71389e6091bb94e6dd30c0c /monitor
parent4b4dd18254bddf98bbb12c863db3eea5ec5e6413 (diff)
[monitor] Add installation script
This script will check all the dependencies, create the base infrastrcture and provide post-installation instructions to enable the monitor. Change-Id: I948cf7fa43738a9624b525eee2e5bfb516331c7a
Diffstat (limited to 'monitor')
-rwxr-xr-xmonitor/install.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/monitor/install.sh b/monitor/install.sh
new file mode 100755
index 0000000..64fe278
--- /dev/null
+++ b/monitor/install.sh
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+
+# This script installs the monitor on a new machine.
+#
+# Syntax: install.sh [/root/install/dir]
+#
+# ROOT default is $HOME.
+#
+# Instructions:
+# 1. Create a monitor user, its directory and give admins sudo -u monitor
+# 2. Make sure that Perl, File, JSON and LWP are installed
+# 3. Go to linaro-scripts/monitor; ./install.sh
+# 4. Follow the instructions
+
+# Full path
+BASE=`readlink -fn -- "$0"`
+BASE=`dirname "$BASE"`
+if [ ! -x "$BASE/bot-status" ]; then
+ echo "Make sure the install script is in the monitor directory"
+ exit 1
+fi
+
+############################# Prepare
+
+# Default root is home
+ROOT="$HOME"
+if [ "$1" != "" ]; then
+ ROOT="$1"
+fi
+
+# If there is more than one JSON file, don't guess
+JSON=
+MANY=0
+for json in "$BASE"/*.json; do
+ if [ "$JSON" = "" ]; then
+ JSON="`basename $json`"
+ else
+ MANY=1
+ fi
+done
+if [ $MANY -eq 1 ]; then
+ JSON=""
+fi
+
+# Checking for required Perl modules
+if ! perl -v > /dev/null; then
+ echo "Please, install Perl"
+ exit 1
+fi
+if ! perl -e "File::Temp" > /dev/null; then
+ echo "Please, install Perl's File module"
+ exit 1
+fi
+if ! perl -e "use JSON" > /dev/null; then
+ echo "Please, install Perl's JSON module"
+ exit 1
+fi
+if ! perl -e "use LWP" > /dev/null; then
+ echo "Please, install Perl's LWP module"
+ exit 1
+fi
+
+############################# Install
+
+# Creates bin for bot-status
+mkdir -p "$ROOT/bin"
+ln -sf "$BASE/bot-status" "$ROOT/bin/bot-status"
+if [ "$JSON" != "" ]; then
+ ln -sf "$BASE/$JSON" "$ROOT/bin/$JSON"
+fi
+
+# Creates html dir for page and icons
+mkdir -p "$ROOT/html"
+ln -sf "$BASE/fail.ico" "$ROOT/html/fail.ico"
+ln -sf "$BASE/ok.ico" "$ROOT/html/ok.ico"
+touch "$ROOT/html/index.html"
+
+echo
+echo "Installation complete"
+echo
+
+############################# Instructions
+
+echo
+echo "Post-Install instructions:"
+echo
+
+# JSON configuration
+if [ "$JSON" = "" ]; then
+ echo " * Multiple or empty JSON files, symlink the right one to $ROOT/bin"
+ echo
+ JSON="<json file>"
+fi
+
+# WebServer
+echo " * To make the HTML pages available to your WebServer,"
+echo " Create a link from the web server (ex. /var/www/html/monitor) to $ROOT/html"
+echo
+
+# Crontab
+echo " * To run the application every five minutes, add this line to your crontab:"
+echo " */5 * * * * $ROOT/bin/bot-status $ROOT/bin/$JSON $ROOT/html/index/html"
+echo