IMPROVE: Rearanged configparser.sh

Added Comments for Usage

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2021-12-08 21:15:52 +01:00
parent cad2acb3c6
commit 5e2d40741e
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639

View File

@ -29,6 +29,7 @@ function get_param {
} 2> /dev/null
# Check for existing file
# Exit with error if not exist
function check_cfg {
if [ ! -r "${1}" ]; then
log_msg "ERROR: No Configuration File found. Exiting!"
@ -36,6 +37,17 @@ function check_cfg {
fi
}
## Spits out all [cam <nameornumber>] configured sections
function configured_cams {
local cam_count cfg
cfg="${WEBCAMD_CFG}"
cams="$(crudini --existing=file --get "${cfg}" | \
sed '/webcamd/d;s/cam//')"
echo "${cams}"
}
# Checks [cam <nameornumber>] if all needed configuration sections are present
# call check_section <nameornumber> ex.: check_section foobar
function check_section {
local section param must_exist missing
section="cam ${1}"
@ -54,12 +66,3 @@ function check_section {
Continue..."
fi
}
## Spits out all [cam <nameornumber>] configured sections
function configured_cams {
local cam_count cfg
cfg="${WEBCAMD_CFG}"
cams="$(crudini --existing=file --get "${cfg}" | \
sed '/webcamd/d;s/cam//')"
echo "${cams}"
}