feat: Improved Samba logging

This commit is contained in:
Kroese 2025-10-03 02:48:40 +02:00 committed by GitHub
parent 5659082f99
commit a305488cf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,38 +118,36 @@ for dir in "${dirs[@]}"; do
addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!" addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!"
done done
# Try to fix Samba permissions # Try to repair Samba permissions
[ -d /run/samba/msg.lock ] && chmod -R 0755 /run/samba/msg.lock 2>/dev/null || : [ -d /run/samba/msg.lock ] && chmod -R 0755 /run/samba/msg.lock 2>/dev/null || :
[ -d /var/log/samba/cores ] && chmod -R 0700 /var/log/samba/cores 2>/dev/null || : [ -d /var/log/samba/cores ] && chmod -R 0700 /var/log/samba/cores 2>/dev/null || :
[ -d /var/cache/samba/msg.lock ] && chmod -R 0755 /var/cache/samba/msg.lock 2>/dev/null || : [ -d /var/cache/samba/msg.lock ] && chmod -R 0755 /var/cache/samba/msg.lock 2>/dev/null || :
if [[ "$SAMBA_DEBUG" != [Yy1]* ]]; then rm -f /var/log/samba/log.smbd
if ! smbd; then
if ! smbd -l /var/log/samba; then
SAMBA_DEBUG="Y" SAMBA_DEBUG="Y"
error "Samba daemon failed to start!" error "Failed to start Samba daemon!"
fi
fi fi
if [[ "$SAMBA_DEBUG" == [Yy1]* ]]; then if [[ "$SAMBA_DEBUG" == [Yy1]* ]]; then
smbd -i -d "$SAMBA_LEVEL" --debug-stdout & tail -fn +0 /var/log/samba/log.smbd &
fi fi
[[ "${NETWORK,,}" == "user"* ]] && return 0
if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then
# Enable NetBIOS on Windows 7 and lower # Enable NetBIOS on Windows 7 and lower
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting NetBIOS daemon..." [[ "$DEBUG" == [Yy1]* ]] && echo "Starting NetBIOS daemon..."
if [[ "$SAMBA_DEBUG" != [Yy1]* ]]; then rm -f /var/log/samba/log.nmbd
if ! nmbd; then
if ! nmbd -l /var/log/samba; then
SAMBA_DEBUG="Y" SAMBA_DEBUG="Y"
error "NetBIOS daemon failed to start!" error "Failed to start NetBIOS daemon!"
fi
fi fi
if [[ "$SAMBA_DEBUG" == [Yy1]* ]]; then if [[ "$SAMBA_DEBUG" == [Yy1]* ]]; then
nmbd -i -d "$SAMBA_LEVEL" --debug-stdout & tail -fn +0 /var/log/samba/log.nmbd &
fi fi
else else
@ -157,10 +155,15 @@ else
# Enable Web Service Discovery on Vista and up # Enable Web Service Discovery on Vista and up
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting Web Service Discovery daemon..." [[ "$DEBUG" == [Yy1]* ]] && echo "Starting Web Service Discovery daemon..."
if [[ "$SAMBA_DEBUG" != [Yy1]* ]]; then rm -f /var/log/wsddn.log
wsddn -i "$interface" -H "$hostname" --unixd --pid-file=/var/run/wsdd.pid
else if ! wsddn -i "$interface" -H "$hostname" --unixd --log-file=/var/log/wsddn.log --pid-file=/var/run/wsdd.pid; then
wsddn -i "$interface" -H "$hostname" --pid-file=/var/run/wsdd.pid & SAMBA_DEBUG="Y"
error "Failed to start WSDDN daemon!"
fi
if [[ "$SAMBA_DEBUG" == [Yy1]* ]]; then
tail -fn +0 /var/log/wsddn.log &
fi fi
fi fi