mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 13:35:13 +08:00
🛸 Sync 2026-07-10 20:47:34
This commit is contained in:
1 parent
bc43e5009d
commit
bdfb23c9ce
25 files changed
+3111
-2838
No files matched your search
@@ -7,7 +7,6 @@ config baidudrive
|
||||
option 'sdk_host' '127.0.0.1'
|
||||
option 'sdk_port' '8001'
|
||||
option 'macid' ''
|
||||
option 'device_type' ''
|
||||
option 'usb_path' ''
|
||||
option 'download_path' '/'
|
||||
option 'quota_path' ''
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
START=93
|
||||
USE_PROCD=1
|
||||
DEVICE_TYPE="202604101148240791"
|
||||
|
||||
get_config() {
|
||||
config_section="$1"
|
||||
config_get_bool enabled "$1" enabled 1
|
||||
config_get data_dir "$1" data_dir ""
|
||||
config_get host "$1" host "0.0.0.0"
|
||||
@@ -12,7 +14,6 @@ get_config() {
|
||||
config_get sdk_host "$1" sdk_host "127.0.0.1"
|
||||
config_get sdk_port "$1" sdk_port "8001"
|
||||
config_get macid "$1" macid ""
|
||||
config_get device_type "$1" device_type ""
|
||||
config_get usb_path "$1" usb_path ""
|
||||
config_get download_path "$1" download_path "/"
|
||||
config_get quota_path "$1" quota_path ""
|
||||
@@ -53,6 +54,33 @@ storage_root_from_data_dir() {
|
||||
df -P "$path" 2>/dev/null | awk 'NR == 2 { print $6 }'
|
||||
}
|
||||
|
||||
default_macid() {
|
||||
local netdev mac
|
||||
for netdev in br-lan eth0 lan0; do
|
||||
if [ -r "/sys/class/net/$netdev/address" ]; then
|
||||
mac="$(tr -d ':' <"/sys/class/net/$netdev/address")"
|
||||
if [ -n "$mac" ]; then
|
||||
printf '%s\n' "$mac"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_macid() {
|
||||
if [ -n "$macid" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
macid="$(default_macid)"
|
||||
if [ -n "$macid" ] && [ -n "$config_section" ]; then
|
||||
uci set "baidudrive.$config_section.macid=$macid"
|
||||
uci commit baidudrive
|
||||
logger -t baidudrive "generated macid from network interface: $macid"
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load baidudrive
|
||||
config_foreach get_config baidudrive
|
||||
@@ -61,8 +89,8 @@ start_service() {
|
||||
fi
|
||||
|
||||
require_start_value data_dir "$data_dir" || return 1
|
||||
ensure_macid
|
||||
require_start_value macid "$macid" || return 1
|
||||
require_start_value device_type "$device_type" || return 1
|
||||
require_executable /usr/sbin/baidudrive || return 1
|
||||
require_executable "$sdk_dir/baiduNas" || return 1
|
||||
require_executable "$sdk_dir/P2PClient" || return 1
|
||||
@@ -91,7 +119,7 @@ start_service() {
|
||||
-ip "$sdk_host" \
|
||||
-port "$sdk_port" \
|
||||
-macid "$macid" \
|
||||
-type "$device_type" \
|
||||
-type "$DEVICE_TYPE" \
|
||||
-tmppath "$tmp_path" \
|
||||
-usbpath "$usb_path" \
|
||||
-downloadpath "$download_path" \
|
||||
@@ -122,7 +150,7 @@ start_service() {
|
||||
procd_open_instance baidudrive
|
||||
procd_set_param env \
|
||||
BAIDU_NAS_MACID="$macid" \
|
||||
BAIDU_NAS_DEVICE_TYPE="$device_type" \
|
||||
BAIDU_NAS_DEVICE_TYPE="$DEVICE_TYPE" \
|
||||
BAIDU_NAS_USB_PATH="$usb_path" \
|
||||
BAIDU_NAS_QUOTA_PATH="$quota_path"
|
||||
procd_set_param command /usr/sbin/baidudrive --host "$host" --port "$port" --data "$data_dir"
|
||||
|
||||
Reference in new issue
Block a user