Add -I include parameter to samba.sh (#143)

This commit is contained in:
Sven Grunewaldt 2018-09-23 18:57:54 +02:00 committed by David Personette
parent e65c9b765f
commit 2b1b0c2527
2 changed files with 18 additions and 1 deletions

View File

@ -63,6 +63,9 @@ OR set local storage:
required arg: "<workgroup>" required arg: "<workgroup>"
<workgroup> for samba <workgroup> for samba
-W Allow access wide symbolic links -W Allow access wide symbolic links
-I Add an include option at the end of the smb.conf
required arg: "<include file path>"
<include file path> in the container, e.g. a bind mount
The 'command' (if provided and valid) will be run instead of samba The 'command' (if provided and valid) will be run instead of samba
@ -82,6 +85,7 @@ ENVIRONMENT VARIABLES
* `WORKGROUP` - As above, set workgroup * `WORKGROUP` - As above, set workgroup
* `USERID` - Set the UID for the samba server * `USERID` - Set the UID for the samba server
* `GROUPID` - Set the GID for the samba server * `GROUPID` - Set the GID for the samba server
* `INCLUDE` - As above, add a smb.conf include
**NOTE**: if you enable nmbd (via `-n` or the `NMBD` environment variable), you **NOTE**: if you enable nmbd (via `-n` or the `NMBD` environment variable), you
will also want to expose port 137 and 138 with `-p 137:137/udp -p 138:138/udp`. will also want to expose port 137 and 138 with `-p 137:137/udp -p 138:138/udp`.

View File

@ -45,6 +45,14 @@ global() { local key="${1%%=*}" value="${1#*=}" file=/etc/samba/smb.conf
fi fi
} }
### include: add a samba config file include
# Arguments:
# file) file to import
include() { local includefile="$1" file=/etc/samba/smb.conf
sed -i "\\|include = $includefile|d" "$file"
echo "include = $includefile" >> "$file"
}
### import: import a smbpasswd file ### import: import a smbpasswd file
# Arguments: # Arguments:
# file) file to import # file) file to import
@ -193,6 +201,9 @@ Options (fields in '[]' are optional, '<>' are required):
required arg: \"<workgroup>\" required arg: \"<workgroup>\"
<workgroup> for samba <workgroup> for samba
-W Allow access wide symbolic links -W Allow access wide symbolic links
-I Add an include option at the end of the smb.conf
required arg: \"<include file path>\"
<include file path> in the container, e.g. a bind mount
The 'command' (if provided and valid) will be run instead of samba The 'command' (if provided and valid) will be run instead of samba
" >&2 " >&2
@ -202,7 +213,7 @@ The 'command' (if provided and valid) will be run instead of samba
[[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser [[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser
[[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users [[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users
while getopts ":hc:g:i:nprs:Su:Ww:" opt; do while getopts ":hc:g:i:nprs:Su:Ww:I:" opt; do
case "$opt" in case "$opt" in
h) usage ;; h) usage ;;
c) charmap "$OPTARG" ;; c) charmap "$OPTARG" ;;
@ -216,6 +227,7 @@ while getopts ":hc:g:i:nprs:Su:Ww:" opt; do
u) eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;; u) eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;;
w) workgroup "$OPTARG" ;; w) workgroup "$OPTARG" ;;
W) widelinks ;; W) widelinks ;;
I) include "$OPTARG" ;;
"?") echo "Unknown option: -$OPTARG"; usage 1 ;; "?") echo "Unknown option: -$OPTARG"; usage 1 ;;
":") echo "No argument value for option: -$OPTARG"; usage 2 ;; ":") echo "No argument value for option: -$OPTARG"; usage 2 ;;
esac esac
@ -232,6 +244,7 @@ shift $(( OPTIND - 1 ))
[[ "${USER:-""}" ]] && eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $USER) [[ "${USER:-""}" ]] && eval user $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $USER)
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP" [[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
[[ "${WIDELINKS:-""}" ]] && widelinks [[ "${WIDELINKS:-""}" ]] && widelinks
[[ "${INCLUDE:-""}" ]] && include "$INCLUDE"
if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then
exec "$@" exec "$@"