-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·50 lines (40 loc) · 1.21 KB
/
install
File metadata and controls
executable file
·50 lines (40 loc) · 1.21 KB
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
#!/bin/bash
source ./bits/bootstrap/logging
set -euo pipefail ; IFS=$'\n\t'
#-----------
# Configurations
#-----------
MONIT_PORT=${MONIT_PORT-4001}
MONIT_HOST=${MONIT_HOST-127.0.0.1}
MONIT_USER=${MONIT_USER-monit}
MONIT_PASSWORD=${MONIT_PASSWORD-monit}
MONIT_CONF_DIR=${MONIT_CONF_DIR-/etc/monit/conf.d}
#-----------
# Install Script
#-----------
DESIRED_VERSION="5.5.1"
BASEDIR=./bits/monit/files
if [[ "`which monit 2> /dev/null`" == "" ]]; then
MONIT_NAME=monit-$DESIRED_VERSION
MONIT_EXT='linux-x86'
MACHINE=$(uname -m)
if [[ "$MACHINE" == 'x86_64' ]]; then
MONIT_EXT='linux-x64'
fi
(cd $BASEDIR && tar zxf ./$MONIT_NAME-$MONIT_EXT.tar.gz)
cp $BASEDIR/$MONIT_NAME/bin/monit /usr/local/bin/monit
fi
cp $BASEDIR/monit_default /etc/default/monit
cp $BASEDIR/monit.conf /etc/init/monit.conf
cp $BASEDIR/monitrc /etc/monitrc
sed -i s/@MONIT_PORT@/$MONIT_PORT/g /etc/monitrc
sed -i s/@MONIT_HOST@/$MONIT_HOST/g /etc/monitrc
sed -i s/@MONIT_USER@/$MONIT_USER/g /etc/monitrc
sed -i s/@MONIT_PASSWORD@/$MONIT_PASSWORD/g /etc/monitrc
chmod 700 /etc/monitrc
mkdir -p $MONIT_CONF_DIR
initctl reload-configuration
MONIT_STATUS=`status monit`
if [[ "$MONIT_STATUS" == "monit stop/waiting" ]]; then
start monit
fi