Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data
user.passwd
*~
docker-compose.yml_off
docker-compose.yml_priv
1 change: 1 addition & 0 deletions 2.4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~
3 changes: 3 additions & 0 deletions conf/conf-available/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dav.conf_test
dav.conf_user_block_
test.sh
45 changes: 45 additions & 0 deletions conf/conf-available/dav.conf_multi_user
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
DavLockDB "/var/lib/dav/DavLock"
# transfer
Alias $Location/transfer "/var/lib/dav/data/transfer/"

<Directory "/var/lib/dav/data/transfer/">
Dav On
Options Indexes FollowSymLinks
IndexOptions Charset=UTF-8
DirectoryIndex disabled
IndexOptions FancyIndexing
IndexOptions HTMLTable
IndexOptions SuppressDescription
IndexOptions SuppressRules
IndexOptions NameWidth=*
IndexOrderDefault Ascending Name
IndexOptions IgnoreCase
IndexOptions FoldersFirst
IndexOptions VersionSort
AuthType Basic
AuthName "WebDAV"
AuthUserFile "/user.passwd"
<RequireAny>
Require valid-user
</RequireAny>
</Directory>

<Location "$Location/transfer/">
Require valid-user
</Location>

#placeholder_for_user_block

# These disable redirects on non-GET requests for directories that
# don't include the trailing slash (for misbehaving clients).
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^Microsoft-WebDAV-MiniRedir" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
BrowserMatch " Konqueror/4" redirect-carefully
BrowserMatch "^gvfs" redirect-carefully
BrowserMatch "^Jakarta-Commons-VFS" redirect-carefully
File renamed without changes.
30 changes: 30 additions & 0 deletions conf/conf-available/dav.conf_user_block
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# $user \
Alias $Location/$user "/var/lib/dav/data/$user/"\
\
<Directory "/var/lib/dav/data/$user/">\
Dav On\
Options Indexes FollowSymLinks\
IndexOptions Charset=UTF-8\
DirectoryIndex disabled\
IndexOptions FancyIndexing\
IndexOptions HTMLTable\
IndexOptions SuppressDescription\
IndexOptions SuppressRules\
IndexOptions NameWidth=*\
IndexOrderDefault Ascending Name\
IndexOptions IgnoreCase\
IndexOptions FoldersFirst\
IndexOptions VersionSort\
AuthType Basic\
AuthName "WebDAV"\
AuthUserFile "/user.passwd"\
<RequireAny>\
Require valid-user \
</RequireAny>\
</Directory>\
\
<Location "$Location/$user/">\
Require user $user\
</Location>\
\
\
32 changes: 27 additions & 5 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ HTTPD_PREFIX="${HTTPD_PREFIX:-/usr/local/apache2}"
PUID=${PUID:-1000}
PGID=${PGID:-1000}

# decide between single user mode (no separate home directories) and
# multi user mode (separate dedicated home directories and one shared transfer folder)

if [ ! -e "/user.passwd" ]; then
cp "$HTTPD_PREFIX/conf/conf-available/dav.conf_single_user" "$HTTPD_PREFIX/conf/conf-available/dav.conf"
# Configure dav.conf
if [ "x$LOCATION" != "x" ]; then
sed -e "s|Alias .*|Alias $LOCATION /var/lib/dav/data/|" \
-i "$HTTPD_PREFIX/conf/conf-available/dav.conf"
fi
else
cp "$HTTPD_PREFIX/conf/conf-available/dav.conf_multi_user" "$HTTPD_PREFIX/conf/conf-available/dav.conf"
cat /user.passwd | while read line
do
user=$(echo -n $line|cut -d ":" -f 1)
mkdir -p "/var/lib/dav/data/$user"
user_block=$(cat $HTTPD_PREFIX/conf/conf-available/dav.conf_user_block)
user_block=$(echo "$user_block"|sed -e 's/\$user/'"$user"'/g')
sed 's!#placeholder_for_user_block!'"$user_block"'#placeholder_for_user_block!g' -i $HTTPD_PREFIX/conf/conf-available/dav.conf
done
sed -e 's|$Location|'"${LOCATION:-/}"'|g' \
-i "$HTTPD_PREFIX/conf/conf-available/dav.conf"

fi

# Configure vhosts.
if [ "x$SERVER_NAMES" != "x" ]; then
# Use first domain as Apache ServerName.
Expand All @@ -32,11 +57,6 @@ if [ "x$SERVER_NAMES" != "x" ]; then
-i "$HTTPD_PREFIX"/conf/sites-available/default*.conf
fi

# Configure dav.conf
if [ "x$LOCATION" != "x" ]; then
sed -e "s|Alias .*|Alias $LOCATION /var/lib/dav/data/|" \
-i "$HTTPD_PREFIX/conf/conf-available/dav.conf"
fi
if [ "x$REALM" != "x" ]; then
sed -e "s|AuthName .*|AuthName \"$REALM\"|" \
-i "$HTTPD_PREFIX/conf/conf-available/dav.conf"
Expand Down Expand Up @@ -113,8 +133,10 @@ sed -i -e "s|^Group .*|Group #$PGID|" "$HTTPD_PREFIX/conf/httpd.conf";

# Create directories for Dav data and lock database.
[ ! -d "/var/lib/dav/data" ] && mkdir -p "/var/lib/dav/data"
[ ! -d "/var/lib/dav/data/transfer" ] && mkdir -p "/var/lib/dav/data/transfer"
[ ! -e "/var/lib/dav/DavLock" ] && touch "/var/lib/dav/DavLock"
chown $PUID:$PGID "/var/lib/dav/data"
chown $PUID:$PGID "/var/lib/dav/data/transfer"
chown $PUID:$PGID "/var/lib/dav/DavLock"

# Set umask
Expand Down