create new translation branch for v0.4
This commit is contained in:
parent
9b4e353af7
commit
0a1d2a2e00
795 changed files with 134715 additions and 0 deletions
118
translation-base-v0.4/event-scripts/apache2_dav
Executable file
118
translation-base-v0.4/event-scripts/apache2_dav
Executable file
|
@ -0,0 +1,118 @@
|
|||
#!/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)
|
||||
#
|
||||
# This event script manages apache webdav
|
||||
# - after mounting: add the new webdav share
|
||||
# - before umounting: disable and remove the webdav share
|
||||
#
|
||||
#
|
||||
#
|
||||
# Params: $event $device $volume_name $volume_type $mount_dir
|
||||
#
|
||||
# event: premount | postmount | preumount | postumount
|
||||
# device: name of the device
|
||||
# volume_name: name of the volume
|
||||
# volume_type: plain | luks
|
||||
# mount_dir: mount directory
|
||||
#
|
||||
|
||||
set -eu
|
||||
|
||||
# ------------=-=-=- some settings -=-=-=-----------------
|
||||
# adapt this part of the file to your setup
|
||||
|
||||
APACHE_SCRIPT=/etc/init.d/apache2
|
||||
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"
|
||||
Alias "/cryptonas/_VOLUME_NAME_" "_SHARE_DIR_"
|
||||
# this is an automatically generarted file for the CryptoNAS
|
||||
# please do not change
|
||||
<Location "/cryptonas/_VOLUME_NAME_">
|
||||
Dav filesystem
|
||||
</Location>
|
||||
EOF
|
||||
)
|
||||
|
||||
# no need for changes from here on..
|
||||
# -----=-=-=- check arguments and the environment -=-=-=----
|
||||
|
||||
# exit if apache2 is not installed
|
||||
if test -x "$APACHE_SCRIPT"
|
||||
then true
|
||||
else echo "apache2 is not installed ('$APACHE_SCRIPT' not found)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# create include-file directory
|
||||
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
|
||||
then echo "Syntax: $(basename $0) EVENT [EVENT_INFORMATION]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
event=$1
|
||||
|
||||
# ------------=-=-=- some functions -=-=-=-----------------
|
||||
|
||||
# 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"
|
||||
done
|
||||
}
|
||||
|
||||
empty_conf_dir()
|
||||
{
|
||||
find "$APACHE_CONF_DIR" -type f -name "*.conf" -print0 | xargs -0 rm
|
||||
}
|
||||
|
||||
send_reload_command()
|
||||
{
|
||||
# reload config files
|
||||
"$APACHE_SCRIPT" reload
|
||||
}
|
||||
|
||||
# -----------------=-=-=- main -=-=-=----------------------
|
||||
|
||||
case "$event" in
|
||||
premount|postumount )
|
||||
;;
|
||||
postmount )
|
||||
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"
|
||||
rm "$APACHE_CONF_DIR/${vol_name}.conf" || true
|
||||
update_include_conf_dir
|
||||
send_reload_command
|
||||
;;
|
||||
shutdown | bootup )
|
||||
empty_conf_dir
|
||||
;;
|
||||
* )
|
||||
# ignore all events that we do not support
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue