mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2026-03-21 22:06:45 +08:00
Update generate_config.sh
This commit is contained in:
@ -104,20 +104,23 @@ apply_secret_to_config() {
|
|||||||
|
|
||||||
apply_controller_to_config() {
|
apply_controller_to_config() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
local ui_dir="$RUNTIME_DIR/ui"
|
||||||
|
|
||||||
if [ "$EXTERNAL_CONTROLLER_ENABLED" = "true" ]; then
|
if [ "$EXTERNAL_CONTROLLER_ENABLED" = "true" ]; then
|
||||||
upsert_yaml_kv_local "$file" "external-controller" "$EXTERNAL_CONTROLLER"
|
upsert_yaml_kv_local "$file" "external-controller" "$EXTERNAL_CONTROLLER"
|
||||||
|
|
||||||
local ui_dir
|
|
||||||
ui_dir="$RUNTIME_DIR/ui"
|
|
||||||
|
|
||||||
rm -rf "$ui_dir"
|
rm -rf "$ui_dir"
|
||||||
mkdir -p "$ui_dir"
|
mkdir -p "$ui_dir"
|
||||||
|
|
||||||
if [ -d "$PROJECT_DIR/dashboard/public" ]; then
|
if [ -d "$PROJECT_DIR/dashboard/public" ]; then
|
||||||
cp -a "$PROJECT_DIR/dashboard/public/." "$ui_dir/"
|
cp -a "$PROJECT_DIR/dashboard/public/." "$ui_dir/"
|
||||||
upsert_yaml_kv_local "$file" "external-ui" "$ui_dir"
|
upsert_yaml_kv_local "$file" "external-ui" "$ui_dir"
|
||||||
|
else
|
||||||
|
remove_yaml_key_local "$file" "external-ui"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
remove_yaml_key_local "$file" "external-controller"
|
||||||
|
remove_yaml_key_local "$file" "external-ui"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +164,14 @@ finalize_config() {
|
|||||||
mv -f "$file" "$RUNTIME_CONFIG"
|
mv -f "$file" "$RUNTIME_CONFIG"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_yaml_key_local() {
|
||||||
|
local file="$1"
|
||||||
|
local key="$2"
|
||||||
|
|
||||||
|
[ -f "$file" ] || return 0
|
||||||
|
sed -i -E "/^[[:space:]]*${key}:/d" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local template_file="$CONFIG_DIR/template.yaml"
|
local template_file="$CONFIG_DIR/template.yaml"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user