Skip to content

Commit

Permalink
TRITON-2159 Port /lib/sdc/config.sh to linux
Browse files Browse the repository at this point in the history
  • Loading branch information
kusor authored and bahamat committed Aug 10, 2022
1 parent 472fb61 commit f4b6b84
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions proto/usr/triton/config/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/bash
#
# functions for getting USB headnode config values (intended to be sourced
# from other scripts)
#
# It is also possible to use this to get a JSON hash of the config options using:
#
# bash config.sh -json
#
# Copyright 2020 Joyent Inc.
#

# Sets SDC_CONFIG_FILENAME with the location of the config file.
# On linux this is always the same, this function is here for
# compatibility purposes
function load_sdc_config_filename {
# the default
COMPUTE_NODE_CONFIG_FILENAME="/usr/triton/config/node.config"
SDC_CONFIG_FILENAME=${COMPUTE_NODE_CONFIG_FILENAME}
SDC_CONFIG_INC_DIR="$(dirname ${COMPUTE_NODE_CONFIG_FILENAME})"

}


# Loads config variables with prefix (default: CONFIG_)
function load_sdc_config {

prefix=$1
[[ -z ${prefix} ]] && prefix="CONFIG_"

load_sdc_config_filename
if [[ -f ${SDC_CONFIG_INC_DIR}/generic ]]; then
GEN_FILE=${SDC_CONFIG_INC_DIR}/generic
else
GEN_FILE=/dev/null
fi

# Ignore comments, spaces at the beginning of lines and lines that don't
# start with a letter.
eval $((cat ${GEN_FILE} ${SDC_CONFIG_FILENAME}; echo "config_inc_dir=${SDC_CONFIG_INC_DIR}") | \
sed -e "s/^ *//" | grep -v "^#" | grep "^[a-zA-Z]" | \
sed -e "s/^/${prefix}/")
}

0 comments on commit f4b6b84

Please sign in to comment.