mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 03:35:13 +08:00
💋 Sync 2026-10-04 04:16:09
This commit is contained in:
1 parent
f6b2df73ec
commit
f62992fd80
745 files changed
+212416
-1173
No files matched your search
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
readonly bg_path="/www/luci-static/fluent/background"
|
||||
readonly tmp_path="/tmp/fluent_background.tmp"
|
||||
|
||||
case "$1" in
|
||||
"list")
|
||||
json_init
|
||||
json_add_object "avail"
|
||||
json_close_object
|
||||
json_add_object "remove"
|
||||
json_add_string "filename" "filename"
|
||||
json_close_object
|
||||
json_add_object "rename"
|
||||
json_add_string "newname" "filename"
|
||||
json_close_object
|
||||
json_add_object "set_mode"
|
||||
json_add_string "mode" "mode"
|
||||
json_close_object
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
"call")
|
||||
case "$2" in
|
||||
"avail")
|
||||
json_init
|
||||
json_add_int "avail" "$(df | grep -E '/$' | awk '{print $4}')"
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
"remove")
|
||||
read -r input
|
||||
json_load "$input"
|
||||
json_get_var filename "filename"
|
||||
json_cleanup
|
||||
if dirname "$filename" | grep -q ".."; then
|
||||
echo '{ "result": 255 }'
|
||||
exit 255
|
||||
fi
|
||||
rm -f "$bg_path/$filename"
|
||||
echo '{ "result": 0 }'
|
||||
;;
|
||||
"rename")
|
||||
read -r input
|
||||
json_load "$input"
|
||||
json_get_var newname "newname"
|
||||
json_cleanup
|
||||
if dirname "$newname" | grep -q ".."; then
|
||||
echo '{ "result": 255 }'
|
||||
exit 255
|
||||
fi
|
||||
mkdir -p "$bg_path"
|
||||
if mv "$tmp_path" "$bg_path/$newname" 2>/dev/null; then
|
||||
chmod 0644 "$bg_path/$newname"
|
||||
echo '{ "result": 0 }'
|
||||
else
|
||||
echo '{ "result": 1 }'
|
||||
fi
|
||||
;;
|
||||
"set_mode")
|
||||
read -r input
|
||||
json_load "$input"
|
||||
json_get_var mode "mode"
|
||||
json_cleanup
|
||||
case "$mode" in
|
||||
light|dark|auto) ;;
|
||||
*) echo '{ "result": 255 }'; exit 255 ;;
|
||||
esac
|
||||
if uci -q set fluent.@global[0].mode="$mode" && uci -q commit fluent; then
|
||||
echo '{ "result": 0 }'
|
||||
else
|
||||
echo '{ "result": 1 }'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user