* sed in the webdav event script now works
* share names must not have any whitespaces
This commit is contained in:
parent
2c77ef5ef5
commit
66cf3a013e
3 changed files with 27 additions and 19 deletions
|
@ -1,12 +1,12 @@
|
|||
#!/bin/sh
|
||||
# To make this event script work add the apache2_dav.conf file
|
||||
# from /usr/share/doc/cryptobox/conf-examples/ to your apache
|
||||
# configuration directory (e.g. /etc/apache2/conf.d)
|
||||
#
|
||||
# Manage apache webdav
|
||||
# This event script manages apache webdav
|
||||
# - after mounting: add the new webdav share
|
||||
# - before umounting: disable and remove the webdav share
|
||||
#
|
||||
# This script assumes, that you added the apache2_dav.conf file
|
||||
# (/usr/share/doc/cryptobox/conf-examples/) to your apache configuration directory
|
||||
# (e.g. /etc/apache2/conf.d)
|
||||
#
|
||||
#
|
||||
# Params: $event $device $volume_name $volume_type $mount_dir
|
||||
|
@ -24,19 +24,21 @@ set -eu
|
|||
# adapt this part of the file to your setup
|
||||
|
||||
APACHE_SCRIPT=/etc/init.d/apache2
|
||||
APACHE_CONF_DIR=/var/cache/cryptobox/settings/misc/apache2_dav.conf.d
|
||||
APACHE_CONF_DIR=/var/cache/cryptobox-server/settings/misc/apache2_dav.conf.d
|
||||
|
||||
# this apache config snippet is used for every published volume
|
||||
# _VOLUME_NAME_ and _SHARE_DIR_ are replaced by their actual values
|
||||
APACHE_SHARE_TEMPLATE=$(cat - <<-"EOF"
|
||||
# this file is part of the CryptoBox
|
||||
Alias "/cryptobox/_VOLUME_NAME_" "_SHARE_DIR_"
|
||||
<Location "/cryptobox/_VOLUME_NAME_">
|
||||
Dav filesystem
|
||||
Alias "/cryptonas/_VOLUME_NAME_" "_SHARE_DIR_"
|
||||
# this is an automatically generarted file for the CryptoNAS
|
||||
# please do not change
|
||||
<Location "/cryptonas/_VOLUME_NAME_">
|
||||
\tDav filesystem
|
||||
</Location>
|
||||
EOF
|
||||
)
|
||||
|
||||
# no need for changes from here on..
|
||||
# -----=-=-=- check arguments and the environment -=-=-=----
|
||||
|
||||
# exit if apache2 is not installed
|
||||
|
@ -47,7 +49,11 @@ if test -x "$APACHE_SCRIPT"
|
|||
fi
|
||||
|
||||
# create include-file directory
|
||||
mkdir -p "$APACHE_CONF_DIR"
|
||||
if test ! -d ${APACHE_CONF_DIR}
|
||||
echo "apache2_dav include-file directory does not exist, creating it" >&2
|
||||
then mkdir -p ${APACHE_CONF_DIR}
|
||||
chmod 775 ${APACHE_CONF_DIR}
|
||||
fi
|
||||
|
||||
# check event argument
|
||||
if test "$#" -eq 0
|
||||
|
@ -59,9 +65,11 @@ event=$1
|
|||
|
||||
# ------------=-=-=- some functions -=-=-=-----------------
|
||||
|
||||
# remove invalid config files
|
||||
# keep the include file directory clean
|
||||
update_include_conf_dir()
|
||||
{
|
||||
# if a webdav alias is given but no corresponding mount dir exists
|
||||
# then remove the includefile
|
||||
find "$APACHE_CONF_DIR" -type f -name "*.conf" | while read fname
|
||||
do mdir=$(head -1 "$fname" | cut -f 4 -d '"')
|
||||
test ! -d "$mdir" && rm "$fname"
|
||||
|
@ -85,16 +93,16 @@ case "$event" in
|
|||
premount|postumount )
|
||||
;;
|
||||
postmount )
|
||||
vol_name=$3
|
||||
mount_dir=$5
|
||||
echo "$APACHE_SHARE_TEMPLATE" | sed "s#_SHARE_DIR_#$mount_dir#g; s#_VOLUME_NAME_#$vol_name#g" >"$APACHE_CONF_DIR/${vol_name}.conf"
|
||||
update_include_conf_dir
|
||||
vol_name="$3"
|
||||
mountdir="$5"
|
||||
echo "$APACHE_SHARE_TEMPLATE" | sed s\#_SHARE_DIR_\#"$mountdir"\#g | sed s\#_VOLUME_NAME_\#"$vol_name"\#g > ${APACHE_CONF_DIR}/${vol_name}.conf
|
||||
#update_include_conf_dir
|
||||
send_reload_command
|
||||
;;
|
||||
preumount )
|
||||
vol_name=$3
|
||||
vol_name="$3"
|
||||
rm "$APACHE_CONF_DIR/${vol_name}.conf" || true
|
||||
update_include_conf_dir
|
||||
#update_include_conf_dir
|
||||
send_reload_command
|
||||
;;
|
||||
shutdown | bootup )
|
||||
|
|
|
@ -108,7 +108,7 @@ class CryptoBoxContainer:
|
|||
## is the same as the volume name
|
||||
if self.is_mounted():
|
||||
raise CBVolumeIsActive("the container must not be active during renaming")
|
||||
if not re.search(r'^[a-zA-Z0-9_\.\- ]+$', new_name):
|
||||
if not re.search(r'^[a-zA-Z0-9_\.\-]+$', new_name):
|
||||
raise CBInvalidName("the supplied new name contains illegal characters")
|
||||
## check for another partition with the same name
|
||||
if self.cbox.get_container_list(filter_name=new_name):
|
||||
|
|
|
@ -347,7 +347,7 @@ class WebInterfaceSites:
|
|||
self.__dataset[key] = value
|
||||
## check if the device is busy
|
||||
if plugin.device and self.cbox.get_container(plugin.device).is_busy():
|
||||
return self.__render("volume_busy")
|
||||
return self.__render("volume_busy")
|
||||
## call the plugin handler
|
||||
next_template = plugin.do_action(**args)
|
||||
## for 'volume' plugins: reread the dataset of the current disk
|
||||
|
|
Loading…
Reference in a new issue