samba.sh fix quotations for variables
This commit is contained in:
parent
a7493f31de
commit
b2901a382d
10
samba.sh
10
samba.sh
@ -49,7 +49,7 @@ global() { local key="${1%%=*}" value="${1#*=}" file=/etc/samba/smb.conf
|
|||||||
# Arguments:
|
# Arguments:
|
||||||
# file) file to import
|
# file) file to import
|
||||||
# Return: user(s) added to container
|
# Return: user(s) added to container
|
||||||
import() { local name id file="$1"
|
import() { local file="$1" name id
|
||||||
while read name id; do
|
while read name id; do
|
||||||
grep -q "^$name:" /etc/passwd || adduser -D -H -u "$id" "$name"
|
grep -q "^$name:" /etc/passwd || adduser -D -H -u "$id" "$name"
|
||||||
done < <(cut -d: -f1,2 $file | sed 's/:/ /')
|
done < <(cut -d: -f1,2 $file | sed 's/:/ /')
|
||||||
@ -128,7 +128,7 @@ smb() { local file=/etc/samba/smb.conf
|
|||||||
# id) for user
|
# id) for user
|
||||||
# group) for user
|
# group) for user
|
||||||
# Return: user added to container
|
# Return: user added to container
|
||||||
user() { local name="${1}" passwd="${2}" id="${3:-""}" group="${4:-""}"
|
user() { local name="$1" passwd="$2" id="${3:-""}" group="${4:-""}"
|
||||||
[[ "$group" ]] && { grep -q "^$group:" /etc/group || addgroup "$group"; }
|
[[ "$group" ]] && { grep -q "^$group:" /etc/group || addgroup "$group"; }
|
||||||
grep -q "^$name:" /etc/passwd ||
|
grep -q "^$name:" /etc/passwd ||
|
||||||
adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name"
|
adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name"
|
||||||
@ -139,7 +139,7 @@ user() { local name="${1}" passwd="${2}" id="${3:-""}" group="${4:-""}"
|
|||||||
# Arguments:
|
# Arguments:
|
||||||
# workgroup) the name to set
|
# workgroup) the name to set
|
||||||
# Return: configure the correct workgroup
|
# Return: configure the correct workgroup
|
||||||
workgroup() { local workgroup="${1}" file=/etc/samba/smb.conf
|
workgroup() { local workgroup="$1" file=/etc/samba/smb.conf
|
||||||
sed -i 's|^\( *workgroup = \).*|\1'"$workgroup"'|' $file
|
sed -i 's|^\( *workgroup = \).*|\1'"$workgroup"'|' $file
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ while getopts ":hc:g:i:nprs:Su:Ww:" opt; do
|
|||||||
r) recycle ;;
|
r) recycle ;;
|
||||||
s) eval share $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;;
|
s) eval share $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;;
|
||||||
S) smb ;;
|
S) smb ;;
|
||||||
u) eval user $(sed 's/;/ /g' <<< $OPTARG) ;;
|
u) eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;;
|
||||||
w) workgroup "$OPTARG" ;;
|
w) workgroup "$OPTARG" ;;
|
||||||
W) widelinks ;;
|
W) widelinks ;;
|
||||||
"?") echo "Unknown option: -$OPTARG"; usage 1 ;;
|
"?") echo "Unknown option: -$OPTARG"; usage 1 ;;
|
||||||
@ -229,7 +229,7 @@ shift $(( OPTIND - 1 ))
|
|||||||
[[ "${RECYCLE:-""}" ]] && recycle
|
[[ "${RECYCLE:-""}" ]] && recycle
|
||||||
[[ "${SHARE:-""}" ]] && eval share $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $SHARE)
|
[[ "${SHARE:-""}" ]] && eval share $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $SHARE)
|
||||||
[[ "${SMB:-""}" ]] && smb
|
[[ "${SMB:-""}" ]] && smb
|
||||||
[[ "${USER:-""}" ]] && user $(sed 's/;/ /g' <<< $USER)
|
[[ "${USER:-""}" ]] && eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $USER)
|
||||||
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
|
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
|
||||||
[[ "${WIDELINKS:-""}" ]] && widelinks
|
[[ "${WIDELINKS:-""}" ]] && widelinks
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user