3 # Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html , or the Apache License,
8 # Version 2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0
10 # SPDX-License-Identifier: EPL-1.0 OR Apache-2.0
17 # Print any error messages
18 test "$1" != "" && echo " ERROR: $1"
20 # Print standard usage help
22 This script is used to enable or disable the config datastore
23 persistence. The default state is enabled. The user should
24 restart controller to apply changes. The script can be used
25 before starting controller for the first time.
38 ################################################
39 ## NOTE: Manually restart controller to ##
40 ## apply configuration. ##
41 ################################################
46 function get_cli_params
48 # Check if params have been supplied
49 test $# -eq 0 && usage
51 # First param is on/off
54 # Verify we only have 1 param
55 test $# -ne 1 && usage "Too many parameters"
59 function modify_conf_file
61 if [ "${SWITCH}" == "off" ]; then
62 echo "disabling config datastore persistence"
63 sed -i -e "s/^#persistent=true/persistent=false/" ${CLUSTERCONF}
64 elif [ "${SWITCH}" == "on" ]; then
65 echo "enabling config datastore persistence"
66 sed -i -e "s/^persistent=false/#persistent=true/" ${CLUSTERCONF}
68 usage "Allowed values are on/off"
73 function verify_configuration_file
77 test ${BIN_DIR} == '.' && BIN_DIR=${PWD}
78 CONTROLLER_DIR=`dirname ${BIN_DIR}`
79 CONF_DIR=${CONTROLLER_DIR}/etc
80 CLUSTERCONF=${CONF_DIR}/org.opendaylight.controller.cluster.datastore.cfg
82 # Verify configuration files are present in expected location.
83 if [ ! -f ${CLUSTERCONF} ]; then
84 # Check if the configuration files exist in the system
85 # directory, then copy them over.
86 ORIG_CONF_DIR=${CONTROLLER_DIR}/system/org/opendaylight/controller/sal-clustering-config
87 version=$(sed -n -e 's/.*<version>\(.*\)<\/version>/\1/p' ${ORIG_CONF_DIR}/maven-metadata-local.xml)
88 ORIG_CONF_DIR=${ORIG_CONF_DIR}/${version}
89 ORIG_CLUSTER_CONF=sal-clustering-config-${version}-datastore.cfg
91 if [ -f ${ORIG_CONF_DIR}/${ORIG_CLUSTER_CONF} ]; then
93 NOTE: Cluster configuration file not found. Copying from
96 cp ${ORIG_CONF_DIR}/${ORIG_CLUSTER_CONF} ${CLUSTERCONF}
99 usage "Cluster configuration file not found"
107 verify_configuration_file
114 # vim: ts=4 sw=4 sts=4 et ft=sh :