-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.sh
96 lines (74 loc) · 2.77 KB
/
plugin.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# shellcheck shell=bash
# Bio Plugin Wrapper
# Wraps a package
#
# Variables:
# `pkg_wrapper_for` - original package ident to wrap
#
# Functions:
# `do_wrapper_build_config` - Wraps package configuration
do_default_build_config() {
do_wrapper_build_config
}
do_wrapper_build_config() {
if [[ -z "${pkg_wrapper_for:-}" ]]; then
exit_with "You loaded wrapper plugin but did not specify pkg_wrapper_for." 1
fi
local wrapper_path
wrapper_path="$(pkg_path_for "$pkg_wrapper_for")"
build_line "Copying stock hooks and configs from $pkg_wrapper_for"
if [[ -d "$wrapper_path/config" ]]; then
# shellcheck disable=SC2154
cp -r "$wrapper_path/config" "$pkg_prefix"
fi
if [[ -d "$PLAN_CONTEXT/config" ]]; then
cp -r "$PLAN_CONTEXT/config" "$pkg_prefix"
fi
if [[ -d "$wrapper_path/config_install" ]]; then
cp -r "$wrapper_path/config_install" "$pkg_prefix"
fi
if [[ -d "$PLAN_CONTEXT/config_install" ]]; then
cp -r "$PLAN_CONTEXT/config_install" "$pkg_prefix"
fi
if [[ -d "$wrapper_path/hooks" ]]; then
cp -r "$wrapper_path/hooks" "$pkg_prefix"
fi
if [[ -z "${pkg_svc_run:-}" ]] && [[ -f "$wrapper_path/run" ]]; then
cp "$wrapper_path/run" "$pkg_prefix"
fi
if [[ -d "$PLAN_CONTEXT/hooks" ]]; then
cp -r "$PLAN_CONTEXT/hooks" "$pkg_prefix"
fi
if [[ -f "$pkg_prefix/hooks/health_check" ]]; then
warn "Renaming deprecated health_check to health-check"
mv "$pkg_prefix/hooks/health_check" "$pkg_prefix/hooks/health-check"
fi
if [[ -f "$wrapper_path/default.toml" ]]; then
cp "$wrapper_path/default.toml" "$pkg_prefix"
fi
if [[ -f "$PLAN_CONTEXT/default.toml" ]]; then
cp "$PLAN_CONTEXT/default.toml" "$pkg_prefix"
fi
# shellcheck disable=SC2154
if [[ ${#pkg_binds[@]} -eq 0 ]] && [[ -f "$wrapper_path/BINDS" ]]; then
cp "$wrapper_path/BINDS" "$pkg_prefix"
fi
# shellcheck disable=SC2154
if [[ ${#pkg_binds_optional[@]} -eq 0 ]] && [[ -f "$wrapper_path/BINDS_OPTIONAL" ]]; then
cp "$wrapper_path/BINDS_OPTIONAL" "$pkg_prefix"
fi
# shellcheck disable=SC2154
if [[ ${#pkg_exports[@]} -eq 0 ]] && [[ -f "$wrapper_path/EXPORTS" ]]; then
cp "$wrapper_path/EXPORTS" "$pkg_prefix"
fi
# shellcheck disable=SC2154
if [[ ${#pkg_exposes[@]} -eq 0 ]] && [[ -f "$wrapper_path/EXPOSES" ]]; then
cp "$wrapper_path/EXPOSES" "$pkg_prefix"
fi
if [[ -z "${pkg_shutdown_signal:-}" ]] && [[ -f "$wrapper_path/SHUTDOWN_SIGNAL" ]]; then
cp "$wrapper_path/SHUTDOWN_SIGNAL" "$pkg_prefix"
fi
if [[ -z "${pkg_shutdown_timeout_sec:-}" ]] && [[ -f "$wrapper_path/SHUTDOWN_TIMEOUT" ]]; then
cp "$wrapper_path/SHUTDOWN_TIMEOUT" "$pkg_prefix"
fi
}