samba.sh really fix #76

This commit is contained in:
David Personette 2020-07-02 22:08:03 -04:00
parent 83a0ccc9b9
commit 2a71aed4ca

View File

@ -52,8 +52,8 @@ generic() { local section="$1" key="$(sed 's| *=.*||' <<< $2)" \
# Arguments: # Arguments:
# option) raw option # option) raw option
# Return: line added to smb.conf (replaces existing line with same key) # Return: line added to smb.conf (replaces existing line with same key)
global() { local key="$(sed 's| *=.*||' <<< $1)" \ global() { local key="$(sed 's|\([^=]*\) += .*|\1|' <<< $1)" \
value="$(sed 's|.*= *||' <<< $1)" file=/etc/samba/smb.conf value="$(sed 's|[^=]* += +||' <<< $1)" file=/etc/samba/smb.conf
if sed -n '/^\[global\]/,/^\[/p' $file | grep -qE '^;*\s*'"$key"; then if sed -n '/^\[global\]/,/^\[/p' $file | grep -qE '^;*\s*'"$key"; then
sed -i '/^\[global\]/,/^\[/s|^;*\s*\('"$key"' = \).*| \1'"$value"'|' \ sed -i '/^\[global\]/,/^\[/s|^;*\s*\('"$key"' = \).*| \1'"$value"'|' \
"$file" "$file"