Allow setting super user in stanza config
This commit is contained in:
@@ -34,16 +34,23 @@ Example file is `stanza.sample.cfg`
|
|||||||
|
|
||||||
This files holds the stanzas to backup
|
This files holds the stanzas to backup
|
||||||
|
|
||||||
`stanza:repo number:path to config file`
|
`stanza:repo number:path to config file:super user`
|
||||||
|
|
||||||
If the stanza has several repo settings as in "repo1-...", "repo2-..." then the repo to target can be listed in here by ":repo number"
|
If the stanza has several repo settings as in "repo1-...", "repo2-..." then the repo to target can be listed in here by ":repo number"
|
||||||
|
|
||||||
The third optional parameter is a config file path
|
The third optional parameter is a config file path
|
||||||
|
|
||||||
|
The forth optional parameter is the super user to use
|
||||||
|
|
||||||
|
If parameters are not used but laters are, the empties need to be set with just the ":"
|
||||||
|
|
||||||
|
`stanza::/conifg`
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[stanzas]
|
[stanzas]
|
||||||
stanza_a
|
stanza_a
|
||||||
stanza_b:1
|
stanza_b:1
|
||||||
stanza_b:2
|
stanza_b:2
|
||||||
stanza_c::/etc/to/config
|
stanza_c::/etc/to/config
|
||||||
|
stanza_d:::super user
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ while read -r stanza; do
|
|||||||
stanza_repo=$(echo "${stanza}" | awk -F':' '{print (NF>1) ? $2 : ""}');
|
stanza_repo=$(echo "${stanza}" | awk -F':' '{print (NF>1) ? $2 : ""}');
|
||||||
# if we have a config
|
# if we have a config
|
||||||
stanza_config=$(echo "${stanza}" | awk -F':' '{print (NF>1) ? $3 : ""}');
|
stanza_config=$(echo "${stanza}" | awk -F':' '{print (NF>1) ? $3 : ""}');
|
||||||
|
# for possible override super user
|
||||||
|
stanza_super_user=$(echo "${stanza}" | awk -F':' '{print (NF>3) ? $4 : ""}');
|
||||||
# override stanza check
|
# override stanza check
|
||||||
if [ -n "${OVERRIDE_STANZA}" ]; then
|
if [ -n "${OVERRIDE_STANZA}" ]; then
|
||||||
# skip if not matching name
|
# skip if not matching name
|
||||||
@@ -198,6 +200,7 @@ while read -r stanza; do
|
|||||||
fi;
|
fi;
|
||||||
# set repo from override
|
# set repo from override
|
||||||
stanza_repo="${OVERRIDE_STANZA_REPO}";
|
stanza_repo="${OVERRIDE_STANZA_REPO}";
|
||||||
|
# config
|
||||||
OVERRIDE_STANZA_CONFIG=$(echo "${OVERRIDE_STANZA}" | awk -F':' '{print (NF>2) ? $3 : ""}');
|
OVERRIDE_STANZA_CONFIG=$(echo "${OVERRIDE_STANZA}" | awk -F':' '{print (NF>2) ? $3 : ""}');
|
||||||
# if we have a config set in the stanza config, but none in the override, use the one from the stanza config
|
# if we have a config set in the stanza config, but none in the override, use the one from the stanza config
|
||||||
if [ -z "${OVERRIDE_STANZA_CONFIG}" ] && [ -n "${stanza_config}" ]; then
|
if [ -z "${OVERRIDE_STANZA_CONFIG}" ] && [ -n "${stanza_config}" ]; then
|
||||||
@@ -205,6 +208,17 @@ while read -r stanza; do
|
|||||||
else
|
else
|
||||||
stanza_config="${OVERRIDE_STANZA_CONFIG}";
|
stanza_config="${OVERRIDE_STANZA_CONFIG}";
|
||||||
fi;
|
fi;
|
||||||
|
# super user
|
||||||
|
OVERRIDE_STANZA_SUPER_USER=$(echo "${OVERRIDE_STANZA}" | awk -F':' '{print (NF>3) ? $4 : ""}');
|
||||||
|
if [ -z "${OVERRIDE_STANZA_SUPER_USER}" ] && [ -n "${stanza_super_user}" ]; then
|
||||||
|
OVERRIDE_STANZA_SUPER_USER="${stanza_super_user}";
|
||||||
|
else
|
||||||
|
stanza_super_user="${OVERRIDE_STANZA_SUPER_USER}";
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
# set override sudo user
|
||||||
|
if [ -n "${stanza_super_user}" ]; then
|
||||||
|
sudo_user="${stanza_super_user}";
|
||||||
fi;
|
fi;
|
||||||
# build the call command
|
# build the call command
|
||||||
CALL=(
|
CALL=(
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ stanza_a
|
|||||||
stanza_b:1
|
stanza_b:1
|
||||||
stanza_b:2
|
stanza_b:2
|
||||||
stanca_c::/path/to/config/file
|
stanca_c::/path/to/config/file
|
||||||
|
stanza_d:::super_user
|
||||||
|
|||||||
Reference in New Issue
Block a user