#!/bin/bash set -o nounset # Make sure umask is sane umask 022 # Check for uninitialized variables NOUNSET=${NOUNSET:-} if [[ -n "$NOUNSET" ]]; then set -o nounset fi # TBD: Defaults to $HOME, otherwise if we want to address: # pid path could be /etc/pid_path # monit_script could be # log_path /var/log/monit/ # exec path(for monitrc) could be /etc/monitrc, /usr/local/etc/monitrc # Check if directory for monit logs exists if [ ! -d "$HOME/.bigchaindb-monit" ]; then mkdir -p "$HOME/.bigchaindb-monit" fi monit_pid_path=${MONIT_PID_PATH:=$HOME/.bigchaindb-monit/monit_processes} monit_script_path=${MONIT_SCRIPT_PATH:=$HOME/.bigchaindb-monit/monit_script} monit_log_path=${MONIT_LOG_PATH:=$HOME/.bigchaindb-monit/logs} monit_exec_path=${MONIT_EXEC_PATH:=$HOME} function usage() { cat <${monit_script_path} <> \$3/bigchaindb.out.log 2>> \$3/bigchaindb.err.log & echo \$! > \$2 popd ;; stop_bigchaindb) kill -2 \`cat \$2\` rm -f \$2 ;; start_tendermint) pushd \$4 nohup tendermint node --consensus.create_empty_blocks=false >> \$3/tendermint.out.log 2>> \$3/tendermint.err.log & echo \$! > \$2 popd ;; stop_tendermint) kill -2 \`cat \$2\` rm -f \$2 ;; esac exit 0 EOF chmod +x ${monit_script_path} # configure monitrc cat >${monit_exec_path}/.monitrc <