#!/bin/bash # Report or set the state of d1-processing services # # Usage: view state # # d1processingstate # # Usage: set state to false # # d1processingstate FALSE # CONFIG_ROOT="/etc/dataone/process/" declare -a CONFIG_INFO CONFIG_INFO[0]="synchronization.properties;Synchronization.active" CONFIG_INFO[1]="replication.properties;Replication.active" CONFIG_INFO[2]="logAggregation.properties;LogAggregator.active" CONFIG_INFO[3]="replication.properties;Replication.audit.cn.active" CONFIG_INFO[4]="replication.properties;Replication.audit.mn.active" function report_services_state() { for CF in ${CONFIG_INFO[@]}; do INFO=(${CF//;/ }) grep "${INFO[1]}" "${CONFIG_ROOT}${INFO[0]}" done } function set_services_state() { STATE=${1} if [ "${STATE}" == "TRUE" ] || [ "${STATE}" == "FALSE" ]; then for CF in ${CONFIG_INFO[@]}; do INFO=(${CF//;/ }) echo "Previous: "$(grep "${INFO[1]}" "${CONFIG_ROOT}${INFO[0]}") sed -i 's/^\('${INFO[1]}'\=\).*/\1'${STATE}'/' "${CONFIG_ROOT}${INFO[0]}" echo "New: "$(grep "${INFO[1]}" "${CONFIG_ROOT}${INFO[0]}") done else echo "Invalid state requested: ${STATE}" fi } if [ -z ${1} ]; then report_services_state else set_services_state ${1} fi