Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'etc/library.sh')
-rw-r--r--etc/library.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/etc/library.sh b/etc/library.sh
index 2e58d477..4cfccbe4 100644
--- a/etc/library.sh
+++ b/etc/library.sh
@@ -183,6 +183,29 @@ function find_app_param_num()
}
+install_template() {
+ local template="${1?}"
+ local target="${2?}"
+ local bkp="$(mktemp)"
+ [[ -f "$target" ]] && cp -a "$target" "$bkp"
+ {
+ if [[ "$3" == "--defaults" ]]; then
+ { bash "/usr/local/etc/ncp-templates/$template" --defaults > "$target"; } 2>&1
+ else
+ { bash "/usr/local/etc/ncp-templates/$template" > "$target"; } 2>&1 || \
+ {
+ [[ "$3" == "--allow-fallback" ]] && \
+ { bash "/usr/local/etc/ncp-templates/$template" --defaults > "$target"; } 2>&1
+ }
+ fi
+ } || {
+ echo "ERROR: Could not generate $target from template $template. Rolling back..."
+ mv "$bkp" "$target"
+ return 1
+ }
+ rm "$bkp"
+}
+
find_app_param()
{
local script="${1?}"