Skip to content

Commit

Permalink
chore: refine
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Nov 8, 2024
1 parent 6c1f40e commit 5982568
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ CONFIG_FILE="$1" #config path
#5--value key name in #4 file
#ruby_arr_add_file "$CONFIG_FILE" "['dns']['fallback-filter']['ipcidr']" "0" "/etc/openclash/custom/openclash_custom_fallback_filter.yaml" "['fallback-filter']['ipcidr']"

#Delete Array Value Demo:
#1--config path
#2--key name
#3--value
#ruby_delete "$CONFIG_FILE" "['dns']['nameserver']" "114.114.114.114"

#Delete Key Demo:
#1--config path
#2--key name
#3--key name
#ruby_delete "$CONFIG_FILE" "['dns']" "nameserver"
#ruby_delete "$CONFIG_FILE" "" "dns"

#Ruby Script Demo:
#ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "
# begin
Expand Down
12 changes: 11 additions & 1 deletion luci-app-openclash/root/usr/share/openclash/ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,14 @@ if [ -z "$1" ] || [ -z "$2" ]; then
fi
RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2.each do |i| puts i$3 end}.join"
ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null
}
}

ruby_delete()
{
local Value RUBY_YAML_PARSE
if [ -z "$1" ] || [ -z "$3" ]; then
return
fi
RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2.delete('$3')}.join"
ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null
}

0 comments on commit 5982568

Please sign in to comment.