Update 20-smb

This commit is contained in:
padavanonly
2025-04-09 11:31:23 +08:00
committed by GitHub
parent d568973b6f
commit ecfb1d4d3b

View File

@@ -13,6 +13,15 @@
global=0
config_file="/etc/config/samba4"
[ ! -f /etc/config/samba4 ] && {
echo "
config samba
option workgroup 'WORKGROUP'
option charset 'UTF-8'
option description 'Samba on OpenWRT'
" > $config_file
}
wait_for_init() {
for i in `seq 30`
do
@@ -47,7 +56,6 @@ case "$ACTION" in
sd*);;
md*);;
hd*);;
mmcblk*);;
*) return;;
esac
@@ -55,6 +63,11 @@ case "$ACTION" in
wait_for_init
[ "$(uci -q get samba4.@samba[0].autoshare)" == "1" ] && {
/etc/init.d/samba4 restart
exit 0;
}
cat /proc/mounts | grep -v '/boot\|/opt' | while read j
do
str=${j%% *}
@@ -64,7 +77,7 @@ case "$ACTION" in
global=0
config_foreach smb_handle sambashare $target
name=${target#*/mnt/}
name=$(echo $name | sed -e "s/^\///")
if [ $global -eq 0 ] ;then
echo -e "\n\nconfig sambashare" >> $config_file
echo -e "\toption auto '1'" >> $config_file
@@ -75,12 +88,14 @@ case "$ACTION" in
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 inherit_owner 'yes'" >> $config_file
echo -e "\toption force_root '1'" >> $config_file
/etc/init.d/samba4 reload
return
fi
fi
done
uci -q set samba4.@samba[0].autoshare='1'
uci commit samba4
;;
remove)
@@ -103,4 +118,3 @@ case "$ACTION" in
let i+=1
done
;;
esac