Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable Samba in DHCP mode #93

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
COPY --from=qemux/qemu-arm:1.14 / /
COPY --from=qemux/qemu-arm:1.15 / /

ARG DEBCONF_NOWARNINGS "yes"
ARG DEBIAN_FRONTEND "noninteractive"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
- /home/user/example.iso:/storage/custom.iso
```

Replace the example path `/home/user/example.iso` with the filename of the desired ISO file.
Replace the example path `/home/user/example.iso` with the filename of the desired ISO file. The value of `VERSION` will be ignored in this case.

* ### How do I customize the installation?

Expand Down
27 changes: 16 additions & 11 deletions src/samba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ set -Eeuo pipefail

: "${SAMBA:="Y"}"

[[ "$DHCP" == [Yy1]* ]] && return 0
[[ "$SAMBA" != [Yy1]* ]] && return 0
[[ "$NETWORK" != [Yy1]* ]] && return 0

SHARE="$STORAGE/shared"
hostname="host.lan"
interface="dockerbridge"

mkdir -p "$SHARE"
chmod -R 777 "$SHARE"
if [[ "$DHCP" == [Yy1]* ]]; then
hostname="$IP"
interface="$VM_NET_DEV"
fi

SAMBA="/etc/samba/smb.conf"
share="$STORAGE/shared"

mkdir -p "$share"
[ -z "$(ls -A "$share")" ] && chmod -R 777 "$share"

{ echo "[global]"
echo " server string = Dockur"
echo " netbios name = dockur"
echo " netbios name = $hostname"
echo " workgroup = WORKGROUP"
echo " interfaces = dockerbridge"
echo " interfaces = $interface"
echo " bind interfaces only = yes"
echo " security = user"
echo " guest account = nobody"
Expand All @@ -32,14 +37,14 @@ SAMBA="/etc/samba/smb.conf"
echo " disable spoolss = yes"
echo ""
echo "[Data]"
echo " path = $SHARE"
echo " path = $share"
echo " comment = Shared"
echo " writable = yes"
echo " guest ok = yes"
echo " guest only = yes"
echo " force user = root"
echo " force group = root"
} > "$SAMBA"
} > "/etc/samba/smb.conf"

{ echo "--------------------------------------------------------"
echo " $APP for Docker v$(</run/version)..."
Expand All @@ -59,11 +64,11 @@ SAMBA="/etc/samba/smb.conf"
echo ""
echo "Replace the example path /home/user/example with the desired storage folder."
echo ""
} | unix2dos > "$SHARE/readme.txt"
} | unix2dos > "$share/readme.txt"

! smbd && smbd --debug-stdout

# Enable Web Service Discovery
wsdd -i dockerbridge -p -n "host.lan" &
wsdd -i "$interface" -p -n "$hostname" &

return 0