feat: Improved Samba logging (#1448)

This commit is contained in:
Kroese 2025-10-03 02:50:59 +02:00 committed by GitHub
parent 4871a1e61b
commit f29208af3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 24 deletions

View File

@ -1777,11 +1777,18 @@ prepareInstall() {
echo " Set oFile = Nothing" echo " Set oFile = Nothing"
echo "End With" echo "End With"
echo "" echo ""
} | unix2dos > "$dir/\$OEM\$/admin.vbs" echo "Set oLink = WshShell.CreateShortcut(WshShell.ExpandEnvironmentStrings(\"%userprofile%\\Desktop\\Shared.lnk\"))"
echo "With oLink"
echo " .TargetPath = \"\\\\host.lan\\Data\""
echo " .Save"
echo "End With"
echo "Set oLink = Nothing"
echo ""
} | unix2dos > "$dir/\$OEM\$/install.vbs"
{ echo "[COMMANDS]" { echo "[COMMANDS]"
echo "\"REGEDIT /s install.reg\"" echo "\"REGEDIT /s install.reg\""
echo "\"Wscript admin.vbs\"" echo "\"Wscript install.vbs\""
echo "" echo ""
} | unix2dos > "$dir/\$OEM\$/cmdlines.txt" } | unix2dos > "$dir/\$OEM\$/cmdlines.txt"

View File

@ -5,6 +5,8 @@ set -Eeuo pipefail
: "${SAMBA_DEBUG:="N"}" # Disable debug : "${SAMBA_DEBUG:="N"}" # Disable debug
: "${SAMBA_LEVEL:="1"}" # Debug log level : "${SAMBA_LEVEL:="1"}" # Debug log level
rm -rf /var/run/wsdd.pid
[[ "$SAMBA" == [Nn]* ]] && return 0 [[ "$SAMBA" == [Nn]* ]] && return 0
[[ "$NETWORK" == [Nn]* ]] && return 0 [[ "$NETWORK" == [Nn]* ]] && return 0
@ -40,18 +42,18 @@ addShare() {
echo " For support visit $SUPPORT" echo " For support visit $SUPPORT"
echo "--------------------------------------------------------" echo "--------------------------------------------------------"
echo "" echo ""
echo "Using this folder you can share files with the host machine." echo "Using this folder you can exchange files with the host machine."
echo "" echo ""
echo "To change its location, include the following bind mount in your compose file:" echo "To select the folder you want to share, include the following bind mount in your compose file:"
echo "" echo ""
echo " volumes:" echo " volumes:"
echo " - \"/home/example:/${name,,}\"" echo " - \"./example:/${name,,}\""
echo "" echo ""
echo "Or in your run command:" echo "Or in your run command:"
echo "" echo ""
echo " -v \"/home/example:/${name,,}\"" echo " -v \"\${PWD:-.}/example:/${name,,}\""
echo "" echo ""
echo "Replace the example path /home/example with the desired shared folder." echo "Replace the example path ./example with your desired shared folder."
echo "" echo ""
} | unix2dos > "$dir/readme.txt" } | unix2dos > "$dir/readme.txt"
@ -116,20 +118,20 @@ 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
if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then
@ -137,15 +139,15 @@ 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
@ -153,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