fix(streamlit): Fix ash shell compatibility for nested functions
- Move nested functions outside parent functions (ash doesn't support local functions) - Fix _build_instance_entry and _print_instance_json syntax Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a596eb64d8
commit
34698cac4e
@ -268,9 +268,8 @@ STARTUP
|
||||
}
|
||||
|
||||
# Build instances string from UCI config
|
||||
build_instances_string() {
|
||||
local instances=""
|
||||
local _add_instance() {
|
||||
_instances_result=""
|
||||
_build_instance_entry() {
|
||||
local section="$1"
|
||||
local inst_enabled inst_app inst_port
|
||||
config_get inst_enabled "$section" enabled "0"
|
||||
@ -278,13 +277,16 @@ build_instances_string() {
|
||||
config_get inst_port "$section" port ""
|
||||
|
||||
if [ "$inst_enabled" = "1" ] && [ -n "$inst_app" ] && [ -n "$inst_port" ]; then
|
||||
[ -n "$instances" ] && instances="${instances},"
|
||||
instances="${instances}${inst_app}:${inst_port}"
|
||||
[ -n "$_instances_result" ] && _instances_result="${_instances_result},"
|
||||
_instances_result="${_instances_result}${inst_app}:${inst_port}"
|
||||
fi
|
||||
}
|
||||
|
||||
build_instances_string() {
|
||||
_instances_result=""
|
||||
config_load "$CONFIG"
|
||||
config_foreach _add_instance instance
|
||||
echo "$instances"
|
||||
config_foreach _build_instance_entry instance
|
||||
echo "$_instances_result"
|
||||
}
|
||||
|
||||
# Create LXC config
|
||||
@ -740,13 +742,8 @@ cmd_service_stop() {
|
||||
}
|
||||
|
||||
# Instance management
|
||||
cmd_instance_list() {
|
||||
load_config
|
||||
echo "{"
|
||||
echo ' "instances": ['
|
||||
|
||||
local first=1
|
||||
_list_instance() {
|
||||
_instance_list_first=1
|
||||
_print_instance_json() {
|
||||
local section="$1"
|
||||
local name app port enabled
|
||||
config_get name "$section" name "$section"
|
||||
@ -754,13 +751,20 @@ cmd_instance_list() {
|
||||
config_get port "$section" port ""
|
||||
config_get enabled "$section" enabled "0"
|
||||
|
||||
[ $first -eq 0 ] && echo ","
|
||||
first=0
|
||||
[ "$_instance_list_first" -eq 0 ] && echo ","
|
||||
_instance_list_first=0
|
||||
printf ' {"id": "%s", "name": "%s", "app": "%s", "port": "%s", "enabled": %s}' \
|
||||
"$section" "$name" "$app" "$port" "$([ "$enabled" = "1" ] && echo "true" || echo "false")"
|
||||
}
|
||||
|
||||
cmd_instance_list() {
|
||||
load_config
|
||||
echo "{"
|
||||
echo ' "instances": ['
|
||||
|
||||
_instance_list_first=1
|
||||
config_load "$CONFIG"
|
||||
config_foreach _list_instance instance
|
||||
config_foreach _print_instance_json instance
|
||||
echo ""
|
||||
echo " ]"
|
||||
echo "}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user