forked from monasca/monasca-agents-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_monasca_ui.sh
executable file
·57 lines (47 loc) · 1.5 KB
/
configure_monasca_ui.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
log() { echo -e "$(date --iso-8601=seconds)" "$1"; }
error() { log "ERROR: $1"; }
warn() { log "WARNING: $1"; }
inf() { log "INFO: $1"; }
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INSTALL_DIR="$(cd "$BIN_DIR/.." && pwd)"
inf "Installation directory: ${INSTALL_DIR}"
inf "Configuring monasca-ui Horizon plugin..."
function process_config() {
LOCAL_SETTINGS_FILE=$(find "${INSTALL_DIR}" -name local_settings.py)
local chrlen=${#LOCAL_SETTINGS_FILE}
if [ "$chrlen" -gt 0 ]; then
if [ "${OVERWRITE_CONF}" = "false" ]; then
warn "${LOCAL_SETTINGS_FILE} already exists"
warn "If you want to overwrite it you need to use '--overwrite_conf'"
return
else
inf "Existing ${LOCAL_SETTINGS_FILE} file will be overwritten"
fi
fi
LOCAL_SETTINGS_EX=$(find "${INSTALL_DIR}" -name local_settings.py.example)
if [ -f "${LOCAL_SETTINGS_EX}" ]; then
LOCAL_SETTINGS_FILE="${LOCAL_SETTINGS_EX%.example}"
mv "${LOCAL_SETTINGS_EX}" "${LOCAL_SETTINGS_FILE}"
else
error "No ${LOCAL_SETTINGS_EX} found to replace local_settings.py"
exit 1
fi
warn "Make sure to update monasca-ui configuration before restarting Horizon. Configuration file: ${LOCAL_SETTINGS_FILE}"
}
OVERWRITE_CONF=false
# Check for additional arguments in call to overwrite default values (above)
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-o|--overwrite_conf)
OVERWRITE_CONF=true
shift
;;
*) # other options
shift
;;
esac
done
process_config