mirror of
https://github.com/unraid/api.git
synced 2026-01-02 06:30:02 -06:00
Compare commits
1 Commits
feat/mothe
...
refactor/p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0483f4e56 |
@@ -417,6 +417,24 @@ appendTextIfMissing() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Debug log for env variable
|
||||
echo "PLGTYPE: ${PLGTYPE}"
|
||||
|
||||
# Debug log for SCRIPT_HOME
|
||||
echo "SCRIPT_HOME (if previously set): ${SCRIPT_HOME}"
|
||||
|
||||
# Set the script prefix based on environment
|
||||
if [[ "${PLGTYPE}" == "staging" ]]; then
|
||||
PLUGIN_NAMESPACE="dynamix.unraid.net.staging"
|
||||
else
|
||||
PLUGIN_NAMESPACE="dynamix.unraid.net"
|
||||
fi
|
||||
|
||||
# Set the script home path
|
||||
SCRIPT_HOME="/usr/local/emhttp/plugins/${PLUGIN_NAMESPACE}"
|
||||
. "${SCRIPT_HOME}/script_loader.sh"
|
||||
echo "Loaded script_loader.sh"
|
||||
|
||||
version=
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/unraid-version
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Debug log for env variable
|
||||
echo "Current environment: ${env:-production}"
|
||||
|
||||
# Debug log for SCRIPT_HOME
|
||||
echo "SCRIPT_HOME (if previously set): ${SCRIPT_HOME}"
|
||||
|
||||
# Set the script prefix based on environment
|
||||
if [[ "${env}" == "staging" ]]; then
|
||||
PLUGIN_NAMESPACE="dynamix.unraid.net.staging"
|
||||
else
|
||||
PLUGIN_NAMESPACE="dynamix.unraid.net"
|
||||
fi
|
||||
|
||||
# Set the script home path
|
||||
SCRIPT_HOME="/usr/local/emhttp/plugins/${PLUGIN_NAMESPACE}"
|
||||
|
||||
# Function to run a script with arguments
|
||||
run_script() {
|
||||
local script_name="$1"
|
||||
local script="${SCRIPT_HOME}/${script_name}"
|
||||
shift
|
||||
if [[ -x "${script}" ]]; then
|
||||
"${script}" "$@"
|
||||
else
|
||||
if [[ -f "${script}" ]]; then
|
||||
echo "Script ${script} is not executable"
|
||||
else
|
||||
echo "Script ${script} not found"
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to source a script with arguments
|
||||
source_script() {
|
||||
local script_name="$1"
|
||||
local script="${SCRIPT_HOME}/${script_name}"
|
||||
shift
|
||||
if [[ -f "${script}" ]]; then
|
||||
# disable constant source warning bc dynamic sourcing is intentional
|
||||
# shellcheck disable=SC1090
|
||||
. "${script}" "$@"
|
||||
else
|
||||
echo "Script ${script} not found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user