This commit is contained in:
parent
6d8895966c
commit
6e92342f07
10
README.md
10
README.md
@ -40,7 +40,8 @@ OR set local storage:
|
|||||||
-p Set ownership and permissions on the shares
|
-p Set ownership and permissions on the shares
|
||||||
-r Disable recycle bin for shares
|
-r Disable recycle bin for shares
|
||||||
-S Disable SMB2 minimum version
|
-S Disable SMB2 minimum version
|
||||||
-s "<name;/path>[;browse;readonly;guest;users;admins;wl]" Config a share
|
-s "<name;/path>[;browse;readonly;guest;users;admins;writelist;comment]"
|
||||||
|
Configure a share
|
||||||
required arg: "<name>;</path>"
|
required arg: "<name>;</path>"
|
||||||
<name> is how it's called for clients
|
<name> is how it's called for clients
|
||||||
<path> path to share
|
<path> path to share
|
||||||
@ -51,6 +52,7 @@ OR set local storage:
|
|||||||
[users] allowed default:'all' or list of allowed users
|
[users] allowed default:'all' or list of allowed users
|
||||||
[admins] allowed default:'none' or list of admin users
|
[admins] allowed default:'none' or list of admin users
|
||||||
[writelist] list of users that can write to a RO share
|
[writelist] list of users that can write to a RO share
|
||||||
|
[comment] description of share
|
||||||
-u "<username;password>[;ID;group]" Add a user
|
-u "<username;password>[;ID;group]" Add a user
|
||||||
required arg: "<username>;<passwd>"
|
required arg: "<username>;<passwd>"
|
||||||
<username> for user
|
<username> for user
|
||||||
@ -67,9 +69,15 @@ OR set local storage:
|
|||||||
ENVIRONMENT VARIABLES (only available with `docker run`)
|
ENVIRONMENT VARIABLES (only available with `docker run`)
|
||||||
|
|
||||||
* `CHARMAP` - As above, configure character mapping
|
* `CHARMAP` - As above, configure character mapping
|
||||||
|
* `GLOBAL` - As above, configure a global option
|
||||||
|
* `IMPORT` - As above, import a smbpassword file
|
||||||
* `NMBD` - As above, enable nmbd
|
* `NMBD` - As above, enable nmbd
|
||||||
|
* `PERMISSIONS` - As above, set file permissions on all shares
|
||||||
|
* `RECYCLE` - As above, disable recycle bin
|
||||||
|
* `SHARE` - As above, setup a share
|
||||||
* `SMB` - As above, disable SMB2 minimum version
|
* `SMB` - As above, disable SMB2 minimum version
|
||||||
* `TZ` - Set a timezone, IE `EST5EDT`
|
* `TZ` - Set a timezone, IE `EST5EDT`
|
||||||
|
* `USER` - As above, setup a user
|
||||||
* `WIDELINKS` - As above, allow access wide symbolic links
|
* `WIDELINKS` - As above, allow access wide symbolic links
|
||||||
* `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
|
||||||
|
15
samba.sh
15
samba.sh
@ -86,10 +86,11 @@ recycle() { local file=/etc/samba/smb.conf
|
|||||||
# users) list of allowed users
|
# users) list of allowed users
|
||||||
# admins) list of admin users
|
# admins) list of admin users
|
||||||
# writelist) list of users that can write to a RO share
|
# writelist) list of users that can write to a RO share
|
||||||
|
# comment) description of share
|
||||||
# Return: result
|
# Return: result
|
||||||
share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \
|
share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \
|
||||||
guest=${5:-yes} users=${6:-""} admins=${7:-""} \
|
guest=${5:-yes} users=${6:-""} admins=${7:-""} \
|
||||||
writelist=${8:-""} file=/etc/samba/smb.conf
|
writelist=${8:-""} comment=${9:-""} file=/etc/samba/smb.conf
|
||||||
sed -i "/\\[$share\\]/,/^\$/d" $file
|
sed -i "/\\[$share\\]/,/^\$/d" $file
|
||||||
echo "[$share]" >>$file
|
echo "[$share]" >>$file
|
||||||
echo " path = $path" >>$file
|
echo " path = $path" >>$file
|
||||||
@ -106,6 +107,8 @@ share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \
|
|||||||
echo " admin users = $(tr ',' ' ' <<< $admins)" >>$file
|
echo " admin users = $(tr ',' ' ' <<< $admins)" >>$file
|
||||||
[[ ${writelist:-""} && ! ${writelist:-""} =~ none ]] &&
|
[[ ${writelist:-""} && ! ${writelist:-""} =~ none ]] &&
|
||||||
echo " write list = $(tr ',' ' ' <<< $writelist)" >>$file
|
echo " write list = $(tr ',' ' ' <<< $writelist)" >>$file
|
||||||
|
[[ ${comment:-""} && ! ${comment:-""} =~ none ]] &&
|
||||||
|
echo " comment = $(tr ',' ' ' <<< $comment)" >>$file
|
||||||
echo "" >>$file
|
echo "" >>$file
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +169,8 @@ Options (fields in '[]' are optional, '<>' are required):
|
|||||||
-p Set ownership and permissions on the shares
|
-p Set ownership and permissions on the shares
|
||||||
-r Disable recycle bin for shares
|
-r Disable recycle bin for shares
|
||||||
-S Disable SMB2 minimum version
|
-S Disable SMB2 minimum version
|
||||||
-s \"<name;/path>[;browse;readonly;guest;users;admins;wl]\" Config a share
|
-s \"<name;/path>[;browse;readonly;guest;users;admins;writelist;comment]\"
|
||||||
|
Configure a share
|
||||||
required arg: \"<name>;</path>\"
|
required arg: \"<name>;</path>\"
|
||||||
<name> is how it's called for clients
|
<name> is how it's called for clients
|
||||||
<path> path to share
|
<path> path to share
|
||||||
@ -177,6 +181,7 @@ Options (fields in '[]' are optional, '<>' are required):
|
|||||||
[users] allowed default:'all' or list of allowed users
|
[users] allowed default:'all' or list of allowed users
|
||||||
[admins] allowed default:'none' or list of admin users
|
[admins] allowed default:'none' or list of admin users
|
||||||
[writelist] list of users that can write to a RO share
|
[writelist] list of users that can write to a RO share
|
||||||
|
[comment] description of share
|
||||||
-u \"<username;password>[;ID;group]\" Add a user
|
-u \"<username;password>[;ID;group]\" Add a user
|
||||||
required arg: \"<username>;<passwd>\"
|
required arg: \"<username>;<passwd>\"
|
||||||
<username> for user
|
<username> for user
|
||||||
@ -207,7 +212,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/;/ /g' <<< $OPTARG) ;;
|
||||||
w) workgroup "$OPTARG" ;;
|
w) workgroup "$OPTARG" ;;
|
||||||
W) widelinks ;;
|
W) widelinks ;;
|
||||||
"?") echo "Unknown option: -$OPTARG"; usage 1 ;;
|
"?") echo "Unknown option: -$OPTARG"; usage 1 ;;
|
||||||
@ -217,9 +222,13 @@ done
|
|||||||
shift $(( OPTIND - 1 ))
|
shift $(( OPTIND - 1 ))
|
||||||
|
|
||||||
[[ "${CHARMAP:-""}" ]] && charmap "$CHARMAP"
|
[[ "${CHARMAP:-""}" ]] && charmap "$CHARMAP"
|
||||||
|
[[ "${GLOBAL:-""}" ]] && global "$GLOBAL"
|
||||||
|
[[ "${IMPORT:-""}" ]] && import "$IMPORT"
|
||||||
[[ "${PERMISSIONS:-""}" ]] && perms
|
[[ "${PERMISSIONS:-""}" ]] && perms
|
||||||
[[ "${RECYCLE:-""}" ]] && recycle
|
[[ "${RECYCLE:-""}" ]] && recycle
|
||||||
|
[[ "${SHARE:-""}" ]] && share $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $SHARE)
|
||||||
[[ "${SMB:-""}" ]] && smb
|
[[ "${SMB:-""}" ]] && smb
|
||||||
|
[[ "${USER:-""}" ]] && user $(sed 's/;/ /g' <<< $USER)
|
||||||
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
|
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
|
||||||
[[ "${WIDELINKS:-""}" ]] && widelinks
|
[[ "${WIDELINKS:-""}" ]] && widelinks
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user