mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 16:44:23 +08:00
🍓 Sync 2026-10-03 23:52:06
This commit is contained in:
1 parent
b696d4ef04
commit
d1ce54c61e
2 files changed
-117
No files matched your search
@@ -1,112 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/functions.sh
|
|
||||||
. /lib/functions/service.sh
|
|
||||||
|
|
||||||
global=0
|
|
||||||
config_file="/etc/config/ksmbd"
|
|
||||||
|
|
||||||
wait_for_init() {
|
|
||||||
for i in `seq 30`
|
|
||||||
do
|
|
||||||
if ubus call service list '{"name":"ksmbd"}' 2>/dev/null | grep -q "ksmbd"; then
|
|
||||||
sleep 2
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
smb_handle() {
|
|
||||||
local path
|
|
||||||
config_get path "$1" path
|
|
||||||
if [ -n "$path" ]; then
|
|
||||||
case "$path" in
|
|
||||||
"$2" | "$2"/*) global=1 ;;
|
|
||||||
esac
|
|
||||||
case "$2" in
|
|
||||||
"$path" | "$path"/*) global=1 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
chk_en() {
|
|
||||||
config_get_bool autoshare "$1" autoshare 1
|
|
||||||
[ "$autoshare" -eq 0 ] && exit
|
|
||||||
}
|
|
||||||
|
|
||||||
config_load ksmbd
|
|
||||||
config_foreach chk_en ksmbd
|
|
||||||
|
|
||||||
device=`basename "$DEVPATH"`
|
|
||||||
|
|
||||||
case "$ACTION" in
|
|
||||||
add)
|
|
||||||
|
|
||||||
case "$device" in
|
|
||||||
sd*);;
|
|
||||||
md*);;
|
|
||||||
hd*);;
|
|
||||||
mmcblk*);;
|
|
||||||
nvme*);;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
path="/dev/$device"
|
|
||||||
|
|
||||||
wait_for_init
|
|
||||||
|
|
||||||
grep -v '/boot\|/opt' /proc/mounts | while read -r j
|
|
||||||
do
|
|
||||||
str=${j%% *}
|
|
||||||
if [ "$str" = "$path" ];then
|
|
||||||
strr=${j#* }
|
|
||||||
target=${strr%% *}
|
|
||||||
global=0
|
|
||||||
|
|
||||||
config_load ksmbd
|
|
||||||
config_foreach smb_handle share "$target"
|
|
||||||
|
|
||||||
name=${target#*/mnt/}
|
|
||||||
name=$(echo "$name" | sed -e "s/^\///")
|
|
||||||
|
|
||||||
if [ "$global" -eq 0 ] ;then
|
|
||||||
echo -e "\n\nconfig share" >> $config_file
|
|
||||||
echo -e "\toption auto '1'" >> $config_file
|
|
||||||
echo -e "\toption name '$name'" >> $config_file
|
|
||||||
echo -e "\toption path '$target'" >> $config_file
|
|
||||||
echo -e "\toption read_only 'no'" >> $config_file
|
|
||||||
echo -e "\toption guest_ok 'yes'" >> $config_file
|
|
||||||
echo -e "\toption create_mask '0666'" >> $config_file
|
|
||||||
echo -e "\toption dir_mask '0777'" >> $config_file
|
|
||||||
echo -e "\toption device '$device'" >> $config_file
|
|
||||||
echo -e "\toption force_root '1'" >> $config_file
|
|
||||||
/etc/init.d/ksmbd reload
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
remove)
|
|
||||||
i=0
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
if ! uci -q get ksmbd.@share[$i] >/dev/null; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
dev=$(uci -q get ksmbd.@share[$i].device)
|
|
||||||
if [ "$dev" = "$device" ]; then
|
|
||||||
auto=$(uci -q get ksmbd.@share[$i].auto)
|
|
||||||
if [ "$auto" = "1" ]; then
|
|
||||||
uci delete ksmbd.@share[$i]
|
|
||||||
uci commit ksmbd
|
|
||||||
/etc/init.d/ksmbd reload
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
let i+=1
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
chmod +x /etc/hotplug.d/block/20-smb-ksmbd
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
Reference in new issue
Block a user