feat: Support multiple shared folders (#810)
This commit is contained in:
parent
69b450299c
commit
815a3f3c66
66
src/samba.sh
66
src/samba.sh
@ -14,25 +14,16 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
|||||||
interface="$VM_NET_DEV"
|
interface="$VM_NET_DEV"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
share="/data"
|
addShare() {
|
||||||
|
local dir="$1"
|
||||||
|
local name="$2"
|
||||||
|
local comment="$3"
|
||||||
|
|
||||||
if [ ! -d "$share" ] && [ -d "$STORAGE/data" ]; then
|
mkdir -p "$dir" || return 1
|
||||||
share="$STORAGE/data"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$share" ] && [ -d "/shared" ]; then
|
if [ -z "$(ls -A "$dir")" ]; then
|
||||||
share="/shared"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$share" ] && [ -d "$STORAGE/shared" ]; then
|
chmod 777 "$dir"
|
||||||
share="$STORAGE/shared"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$share"
|
|
||||||
|
|
||||||
if [ -z "$(ls -A "$share")" ]; then
|
|
||||||
|
|
||||||
chmod 777 "$share"
|
|
||||||
|
|
||||||
{ echo "--------------------------------------------------------"
|
{ echo "--------------------------------------------------------"
|
||||||
echo " $APP for Docker v$(</run/version)..."
|
echo " $APP for Docker v$(</run/version)..."
|
||||||
@ -44,17 +35,31 @@ if [ -z "$(ls -A "$share")" ]; then
|
|||||||
echo "To change its location, include the following bind mount in your compose file:"
|
echo "To change its location, include the following bind mount in your compose file:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " volumes:"
|
echo " volumes:"
|
||||||
echo " - \"/home/user/example:/data\""
|
echo " - \"/home/example:/${name,,}\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Or in your run command:"
|
echo "Or in your run command:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -v \"/home/user/example:/data\""
|
echo " -v \"/home/example:/${name,,}\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Replace the example path /home/user/example with the desired shared folder."
|
echo "Replace the example path /home/example with the desired shared folder."
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$share/readme.txt"
|
} | unix2dos > "$dir/readme.txt"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{ echo ""
|
||||||
|
echo "[$name]"
|
||||||
|
echo " path = $dir"
|
||||||
|
echo " comment = $comment"
|
||||||
|
echo " writable = yes"
|
||||||
|
echo " guest ok = yes"
|
||||||
|
echo " guest only = yes"
|
||||||
|
echo " force user = root"
|
||||||
|
echo " force group = root"
|
||||||
|
} >> "/etc/samba/smb.conf"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
{ echo "[global]"
|
{ echo "[global]"
|
||||||
echo " server string = Dockur"
|
echo " server string = Dockur"
|
||||||
@ -72,17 +77,18 @@ fi
|
|||||||
echo " printing = bsd"
|
echo " printing = bsd"
|
||||||
echo " printcap name = /dev/null"
|
echo " printcap name = /dev/null"
|
||||||
echo " disable spoolss = yes"
|
echo " disable spoolss = yes"
|
||||||
echo ""
|
|
||||||
echo "[Data]"
|
|
||||||
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"
|
|
||||||
} > "/etc/samba/smb.conf"
|
} > "/etc/samba/smb.conf"
|
||||||
|
|
||||||
|
share="/data"
|
||||||
|
[ ! -d "$share" ] && [ -d "$STORAGE/data" ] && share="$STORAGE/data"
|
||||||
|
[ ! -d "$share" ] && [ -d "/shared" ] && share="/shared"
|
||||||
|
[ ! -d "$share" ] && [ -d "$STORAGE/shared" ] && share="$STORAGE/shared"
|
||||||
|
|
||||||
|
addShare "$share" "Data" "Shared" || error "Failed to create shared folder!"
|
||||||
|
|
||||||
|
[ -d "/data2" ] && addShare "/data2" "Data2" "Shared"
|
||||||
|
[ -d "/data3" ] && addShare "/data3" "Data3" "Shared"
|
||||||
|
|
||||||
if ! smbd; then
|
if ! smbd; then
|
||||||
error "Samba daemon failed to start!"
|
error "Samba daemon failed to start!"
|
||||||
smbd -i --debug-stdout || true
|
smbd -i --debug-stdout || true
|
||||||
|
Loading…
Reference in New Issue
Block a user