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
13 # Print any error messages
14 test "$1" != "" && echo " ERROR: $1"
16 # Print standard usage help
18 This script is used to enable or disable the config datastore
19 persistence. The default state is enabled. The user should
20 restart controller to apply changes. The script can be used
21 before starting controller for the first time.
34 ################################################
35 ## NOTE: Manually restart controller to ##
36 ## apply configuration. ##
37 ################################################
42 function get_cli_params
44 # Check if params have been supplied
45 test $# -eq 0 && usage
47 # First param is on/off
50 # Verify we only have 1 param
51 test $# -ne 1 && usage "Too many parameters"
55 function modify_conf_file
57 if [ "${SWITCH}" == "off" ]; then
58 echo "disabling config datastore persistence"
59 sed -i -e "s/^#persistent=true/persistent=false/" ${CLUSTERCONF}
60 elif [ "${SWITCH}" == "on" ]; then
61 echo "enabling config datastore persistence"
62 sed -i -e "s/^persistent=false/#persistent=true/" ${CLUSTERCONF}
64 usage "Allowed values are on/off"
69 function verify_configuration_file
73 test ${BIN_DIR} == '.' && BIN_DIR=${PWD}
74 CONTROLLER_DIR=`dirname ${BIN_DIR}`
75 CONF_DIR=${CONTROLLER_DIR}/etc
76 CLUSTERCONF=${CONF_DIR}/org.opendaylight.controller.cluster.datastore.cfg
78 # Verify configuration files are present in expected location.
79 if [ ! -f ${CLUSTERCONF} ]; then
80 # Check if the configuration files exist in the system
81 # directory, then copy them over.
82 ORIG_CONF_DIR=${CONTROLLER_DIR}/system/org/opendaylight/controller/sal-clustering-config
83 version=$(sed -n -e 's/.*<version>\(.*\)<\/version>/\1/p' ${ORIG_CONF_DIR}/maven-metadata-local.xml)
84 ORIG_CONF_DIR=${ORIG_CONF_DIR}/${version}
85 ORIG_CLUSTER_CONF=sal-clustering-config-${version}-datastore.cfg
87 if [ -f ${ORIG_CONF_DIR}/${ORIG_CLUSTER_CONF} ]; then
89 NOTE: Cluster configuration file not found. Copying from
92 cp ${ORIG_CONF_DIR}/${ORIG_CLUSTER_CONF} ${CLUSTERCONF}
95 usage "Cluster configuration file not found"
103 verify_configuration_file
110 # vim: ts=4 sw=4 sts=4 et ft=sh :