summaryrefslogtreecommitdiffstats
path: root/packages/base/src/files
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/files')
-rw-r--r--packages/base/src/files/bin/configure-maven6
-rw-r--r--packages/base/src/files/bin/monitor180
-rw-r--r--packages/base/src/files/bin/policy39
-rwxr-xr-xpackages/base/src/files/etc/cron.d/monitor.cron21
-rw-r--r--packages/base/src/files/etc/profile.d/env.sh10
5 files changed, 115 insertions, 141 deletions
diff --git a/packages/base/src/files/bin/configure-maven b/packages/base/src/files/bin/configure-maven
index 7da5f6a4..34d6de70 100644
--- a/packages/base/src/files/bin/configure-maven
+++ b/packages/base/src/files/bin/configure-maven
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env ash
# ============LICENSE_START=======================================================
# ONAP
@@ -20,14 +20,14 @@
source ${POLICY_HOME}/etc/profile.d/env.sh
-if [[ ${DEBUG} == y ]]; then
+if [ "${DEBUG}" = "y" ]; then
set -x
fi
HOME_M2="${HOME}"/.m2
mkdir -p "${HOME_M2}" 2> /dev/null
-if [[ -z "${SNAPSHOT_REPOSITORY_URL}" && -z "${RELEASE_REPOSITORY_URL}" ]]; then
+if [ -z "${SNAPSHOT_REPOSITORY_URL}" ] && [ -z "${RELEASE_REPOSITORY_URL}" ]; then
ln -s -f "${POLICY_HOME}"/etc/m2/standalone-settings.xml "${HOME_M2}"/settings.xml
else
ln -s -f "${POLICY_HOME}"/etc/m2/settings.xml "${HOME_M2}"/settings.xml
diff --git a/packages/base/src/files/bin/monitor b/packages/base/src/files/bin/monitor
index 6d40f7e2..864582f1 100644
--- a/packages/base/src/files/bin/monitor
+++ b/packages/base/src/files/bin/monitor
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env ash
# ============LICENSE_START=======================================================
# ONAP
@@ -21,122 +21,118 @@
source ${POLICY_HOME}/etc/profile.d/env.sh
function usage() {
- echo -n "syntax: $(basename $0) "
- echo "[--debug]"
+ echo -n "syntax: $(basename $0) "
+ echo "[--debug]"
}
function log() {
- echo "$(date +"%Y-%m-%d_%H-%M-%S") $1" >> ${POLICY_HOME}/logs/monitor.log
+ echo "$(date +"%Y-%m-%d_%H-%M-%S") $1" >> ${POLICY_HOME}/logs/monitor.log
}
function monitor() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
- set -x
- fi
-
- CONTROLLER=$1
- STATUS=$2
-
- if [[ -z ${CONTROLLER} ]]; then
- log "WARNING: invalid invocation: no component provided"
- return
- fi
-
- if [[ -z ${STATUS} ]]; then
- log "WARNING: invalid invocation: no on/off/uninstalled switch provided for ${CONTROLLER}"
- return
- fi
-
- if [[ "${STATUS}" == "off" ]]; then
- off ${CONTROLLER}
- else
- if [[ "${STATUS}" == "on" ]]; then
- on ${CONTROLLER}
- fi
- fi
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- monitor --"
+ set -x
+ fi
+
+ CONTROLLER=$1
+ STATUS=$2
+
+ if [ -z "${CONTROLLER}" ]; then
+ log "WARNING: invalid invocation: no component provided"
+ return
+ fi
+
+ if [ -z "${STATUS}" ]; then
+ log "WARNING: invalid invocation: no on/off/uninstalled switch provided for ${CONTROLLER}"
+ return
+ fi
+
+ if [ "${STATUS}" = "off" ]; then
+ off ${CONTROLLER}
+ else
+ if [ "${STATUS}" = "on" ]; then
+ on ${CONTROLLER}
+ fi
+ fi
}
function on() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
- set -x
- fi
-
- CONTROLLER=$1
-
- ${POLICY_HOME}/bin/${CONTROLLER} status
- if [[ $? != 0 ]]; then
- log "starting ${CONTROLLER}"
-
- # need to make sure we don't pass the lock file descriptor
- ${POLICY_HOME}/bin/${CONTROLLER} umstart {cfg}>&-
- else
- log "OK: ${CONTROLLER} (UP)"
- fi
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- on --"
+ set -x
+ fi
+
+ CONTROLLER=$1
+
+ ${POLICY_HOME}/bin/${CONTROLLER} status
+ if [ $? -ne 0 ]; then
+ log "starting ${CONTROLLER}"
+
+ # need to make sure we don't pass the lock file descriptor
+ ${POLICY_HOME}/bin/${CONTROLLER} umstart 200>&-
+ else
+ log "OK: ${CONTROLLER} (UP)"
+ fi
}
function off() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
- set -x
- fi
-
- CONTROLLER=$1
-
- ${POLICY_HOME}/bin/${CONTROLLER} status
- if [[ $? != 0 ]]; then
- log "OK: ${CONTROLLER} (DOWN)"
-
- else
- log "stopping ${CONTROLLER}"
- ${POLICY_HOME}/bin/${CONTROLLER} umstop
- fi
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- off --"
+ set -x
+ fi
+
+ CONTROLLER=$1
+
+ ${POLICY_HOME}/bin/${CONTROLLER} status
+ if [ $? -ne 0 ]; then
+ log "OK: ${CONTROLLER} (DOWN)"
+
+ else
+ log "stopping ${CONTROLLER}"
+ ${POLICY_HOME}/bin/${CONTROLLER} umstop
+ fi
}
function process_config() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
- set -x
- fi
-
- CONF_FILE=${POLICY_HOME}/etc/monitor/monitor.cfg
- while read line || [ -n "${line}" ]; do
- if [[ -n ${line} ]] && [[ ${line} != *#* ]]; then
- controller=$(echo "${line}" | awk -F = '{print $1;}')
- status=$(echo "${line}" | awk -F = '{print $2;}')
- if [[ -n ${controller} ]] && [[ -n ${status} ]]; then
- monitor ${controller} ${status}
- fi
- fi
- done < "${CONF_FILE}"
- return 0
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- process_config --"
+ set -x
+ fi
+ local lines=$(grep "^[^#;]" ${CON_FILE} 2> /dev/null)
+ for line in ${lines} ; do
+ controller=$(echo "${line}" | awk -F = '{print $1;}')
+ status=$(echo "${line}" | awk -F = '{print $2;}')
+ if [ -n "${controller}" ] && [ -n "${status}" ]; then
+ monitor ${controller} ${status}
+ fi
+ done
+ return 0
}
log "Enter monitor"
DEBUG=n
until [[ -z "$1" ]]; do
- case $1 in
- -d|--debug|debug) DEBUG=y
- set -x
- ;;
- *) usage
- exit 1
- ;;
- esac
- shift
+ case $1 in
+ -d|--debug|debug) DEBUG=y
+ set -x
+ ;;
+ *) usage
+ exit 1
+ ;;
+ esac
+ shift
done
if pidof -o %PPID -x $(basename $0) > /dev/null 2>&1; then
- log "WARNING: $(basename $0) from the previous iteration still running. Exiting."
- exit 1
+ log "WARNING: $(basename $0) from the previous iteration still running. Exiting."
+ exit 1
fi
+CONF_FILE=${POLICY_HOME}/etc/monitor/monitor.cfg
. ${POLICY_HOME}/etc/profile.d/env.sh
-if flock ${cfg} ; then
- process_config
-fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
-
-
+if flock 200 ; then
+ process_config
+fi 200>>${CONF_FILE}.lock
diff --git a/packages/base/src/files/bin/policy b/packages/base/src/files/bin/policy
index 9bc294d8..3ba75f0d 100644
--- a/packages/base/src/files/bin/policy
+++ b/packages/base/src/files/bin/policy
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env ash
# ============LICENSE_START=======================================================
# ONAP
@@ -25,8 +25,8 @@ function usage() {
}
function check_x_file() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- check_x_file --"
set -x
fi
@@ -39,8 +39,8 @@ function check_x_file() {
}
function policy_op() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- policy_op --"
set -x
fi
@@ -53,13 +53,13 @@ function policy_op() {
${BIN_SCRIPT} ${operation} >/tmp/out$$
echo " L [${controller}]: $(sed ':a;N;$!ba;s/\n/ /g' /tmp/out$$)"
else
- echo " L [${controller}]: -"
+ echo " L [${controller}]: -"
fi
}
function policy_status() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- policy_status --"
set -x
fi
@@ -67,14 +67,14 @@ function policy_status() {
policy_op "status"
NUM_CRONS=$(crontab -l 2>/dev/null | wc -l)
- echo " ${NUM_CRONS} cron jobs installed."
+ echo " ${NUM_CRONS} cron jobs installed."
echo
echo "[features]"
features status
local databases=$(ls -d "${POLICY_HOME}"/etc/db/migration/*/ 2>/dev/null)
- if [[ -n ${databases} ]]; then
+ if [ -n "${databases}" ]; then
echo "[migration]"
db-migrator -s ALL -o ok
fi
@@ -82,8 +82,8 @@ function policy_status() {
}
function policy_start() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- policy_start --"
set -x
fi
@@ -91,8 +91,8 @@ function policy_start() {
}
function policy_exec() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- policy_exec --"
set -x
fi
@@ -103,8 +103,8 @@ function policy_exec() {
}
function policy_stop() {
- if [[ $DEBUG == y ]]; then
- echo "-- ${FUNCNAME[0]} --"
+ if [ "$DEBUG" = "y" ]; then
+ echo "-- policy_stop --"
set -x
fi
@@ -119,15 +119,14 @@ function policy_stop() {
source ${POLICY_HOME}/etc/profile.d/env.sh
-if [[ ${DEBUG} == y ]]; then
+if [ "${DEBUG}" = "y" ]; then
echo "-- $0 $* --"
set -x
fi
BIN_SCRIPT="bin/policy-management-controller"
OPERATION=none
-
-until [[ -z "$1" ]]; do
+until [ -z "$1" ]; do
case $1 in
-d | --debug | debug)
DEBUG=y
@@ -166,7 +165,7 @@ halt) ;;
;;
esac
-if [[ -z ${POLICY_HOME} ]]; then
+if [ -z "${POLICY_HOME}" ]; then
echo "error: POLICY_HOME is unset."
exit 1
fi
diff --git a/packages/base/src/files/etc/cron.d/monitor.cron b/packages/base/src/files/etc/cron.d/monitor.cron
deleted file mode 100755
index 338c1d44..00000000
--- a/packages/base/src/files/etc/cron.d/monitor.cron
+++ /dev/null
@@ -1,21 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP
-# ================================================================================
-# Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-* * * * * bash -l -c '${POLICY_HOME}/bin/monitor >/dev/null 2>&1'
diff --git a/packages/base/src/files/etc/profile.d/env.sh b/packages/base/src/files/etc/profile.d/env.sh
index 9ffd026c..a1b9fa7d 100644
--- a/packages/base/src/files/etc/profile.d/env.sh
+++ b/packages/base/src/files/etc/profile.d/env.sh
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/bin/ash
###
# ============LICENSE_START=======================================================
# ONAP
# ================================================================================
-# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@
templateRegex='^\$\{\{POLICY_HOME}}$'
-if [[ -z "${POLICY_HOME}" ]]; then
+if [ -z "${POLICY_HOME}" ]; then
templatedPolicyHome='${{POLICY_HOME}}'
if [[ ! ${templatedPolicyHome} =~ ${templateRegex} ]]; then
POLICY_HOME=${templatedPolicyHome}