mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 11:25:49 +00:00
Update samba.sh
This commit is contained in:
parent
45956f786f
commit
0da3ac29e1
1 changed files with 81 additions and 79 deletions
20
src/samba.sh
20
src/samba.sh
|
|
@ -114,6 +114,8 @@ addUser() {
|
||||||
local password="$1"
|
local password="$1"
|
||||||
local cfg="$5"
|
local cfg="$5"
|
||||||
|
|
||||||
|
if [[ "$groupname" != "root" && "$gid" != "0" ]]; then
|
||||||
|
|
||||||
# Check if the group exists, if not, create it
|
# Check if the group exists, if not, create it
|
||||||
if ! getent group "$groupname" &>/dev/null; then
|
if ! getent group "$groupname" &>/dev/null; then
|
||||||
if ! groupadd -o -g "$gid" "$groupname" > /dev/null; then
|
if ! groupadd -o -g "$gid" "$groupname" > /dev/null; then
|
||||||
|
|
@ -130,6 +132,10 @@ addUser() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$username" != "root" && "$uid" != "0" ]]; then
|
||||||
|
|
||||||
# Check if the user already exists, if not, create it
|
# Check if the user already exists, if not, create it
|
||||||
if ! id "$username" &>/dev/null; then
|
if ! id "$username" &>/dev/null; then
|
||||||
if ! adduser --gid "$gid" --uid "$uid" --comment "$username" --no-create-home --disabled-login "$username"; then
|
if ! adduser --gid "$gid" --uid "$uid" --comment "$username" --no-create-home --disabled-login "$username"; then
|
||||||
|
|
@ -169,11 +175,11 @@ addUser() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
SAMBA_USER="root"
|
|
||||||
SAMBA_GROUP="root"
|
|
||||||
SAMBA_CONFIG="/etc/samba/smb.conf"
|
SAMBA_CONFIG="/etc/samba/smb.conf"
|
||||||
|
|
||||||
{ echo "[global]"
|
{ echo "[global]"
|
||||||
|
|
@ -199,14 +205,10 @@ SAMBA_CONFIG="/etc/samba/smb.conf"
|
||||||
} > "$SAMBA_CONFIG"
|
} > "$SAMBA_CONFIG"
|
||||||
|
|
||||||
# Setup user and group
|
# Setup user and group
|
||||||
if [[ "$SAMBA_UID" != "1000" || "$SAMBA_GID" != "1000" ]]; then
|
[[ "$SAMBA_UID" == "0" ]] && SAMBA_USER="root" || SAMBA_USER="samba"
|
||||||
|
[[ "$SAMBA_GID" == "0" ]] && SAMBA_GROUP="root" || SAMBA_GROUP="samba"
|
||||||
|
|
||||||
SAMBA_USER="samba"
|
! addUser "$SAMBA_USER" "$SAMBA_UID" "$SAMBA_GROUP" "$SAMBA_GID" "$SAMBA_CONFIG" && return 0
|
||||||
SAMBA_GROUP="samba"
|
|
||||||
|
|
||||||
! addUser "$SAMBA_USER" "$SAMBA_UID" "$SAMBA_GROUP" "$SAMBA_GID" "$SAMBA_CONFIG" && return 0
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add shared folders
|
# Add shared folders
|
||||||
share="/shared"
|
share="/shared"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue