create new translation branch for v0.4

This commit is contained in:
lars 2008-04-07 23:08:43 +00:00
parent 9b4e353af7
commit 0a1d2a2e00
795 changed files with 134715 additions and 0 deletions

View file

@ -0,0 +1,35 @@
Event scripts for CryptoBox events
If you want to execute specific actions according to changes of the cryptobox,
then you can just add your own scripts to this directory.
These scripts are called with root user permissions.
The common synopsis for all event scripts is:
SCRIPTNAME EVENT [[EVENT_INFOS]...]
1) Possible events
Supported events:
premount|postmount|preumount|postumount:
called before and after (u)mounting of a volume
arguments (in this order):
- device: name of the underlying device
- vol_name: name of the (u)mounted volume
- vol_type: type of the volume (plain|luks)
- mount_dir: mountpoint of the volume
2) Preperation of event scripts
Every event script has to fulfill the following conditions:
- be executable (for the cryptobox user and for root)
- be writeable for root only
- its parent directories must be writeable for root only
- the directory of the script must contain a file called '_event_scripts_' (to prevent abuse)
3) Storing settings
If your custom event script needs to write information to a file, then it
should create this file below /var/cache/cryptobox-server/settings/misc/.
(adapt this directory to your setup, if you changed the default settings of
[Locations]->SettingsDir)

View file

@ -0,0 +1,6 @@
DO NOT REMOVE THIS FILE
This file is part of the CryptoBox package.
Event scripts in this directory will not get executed, if this file is missing.
It is just a marker ...

View 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

View file

@ -0,0 +1,127 @@
#!/bin/sh
#
# Manage samba shares
# - after mounting: add the new samba share
# - before umounting: disable and remove the samba share
#
# The following line _must_ be added to your /etc/samba/smb.conf:
# include = /var/cache/cryptobox-server/settings/misc/samba-include.conf
# and you should create this file and chown it to the cryptobox user:
# touch /var/cache/cryptobox-server/settings/misc/samba-include.conf
#
#
# 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 needs
SAMBA_CONTROL=smbcontrol
SAMBA_CONF_DIR=/var/cache/cryptobox-server/settings/misc/samba.conf.d
MAIN_SAMBA_CONF_FILE=/var/cache/cryptobox-server/settings/misc/samba-include.conf
# this smb.conf snippet will get used for every published share
# _VOLUME_NAME and _SHARE_DIR_ are replaced by their actual values
SAMBA_SHARE_TEMPLATE=$(cat - <<-"EOF"
[_VOLUME_NAME_]
comment = CryptoBox share
path = _SHARE_DIR_
read only = no
guest ok = yes
EOF
)
# -----=-=-=- check environment and parameters -=-=-=------
# check if samba is installed
if which "$SAMBA_CONTROL"
then true
else echo "samba not installed ('$SAMBA_CONTROL' not found)" >&2
exit 1
fi
# create include-file directory
mkdir -p "$SAMBA_CONF_DIR"
# create the main include file
touch "$MAIN_SAMBA_CONF_FILE"
# check event argument
if test "$#" -eq 0
then echo "Syntax: $(basename $0) EVENT [EVENT_INFORMATION]" >&2
exit 1
fi
event=$1
# ------------=-=-=- some functions -=-=-=-----------------
update_include_conf_file()
{
( echo "# this file was automatically generated by the CryptoBox"
echo "# DO NOT EDIT - all changes will get lost!"
find "$SAMBA_CONF_DIR" -type f -name "*.conf" | while read fname
do mdir=$(grep "path.*=" "$fname" | cut -f 2 -d "=" | sed 's/^[ \t]*//')
# check if the mount directory still exists
if test -d "$mdir"
then echo "include = $fname"
else rm "$fname"
fi
done ) >"$MAIN_SAMBA_CONF_FILE"
}
send_reload_command()
{
# reload config files
"$SAMBA_CONTROL" smbd reload-config
}
empty_conf_dir()
{
find "$SAMBA_CONF_DIR" -type f -name "*.conf" -print0 | xargs -0 rm
}
send_close_share_command()
{
# close all connections and deny further requests
"$SAMBA_CONTROL" smbd close-share "$1"
}
# -----------------=-=-=- main -=-=-=----------------------
case "$event" in
premount|postumount )
;;
postmount )
vol_name=$3
mount_dir=$5
echo "$SAMBA_SHARE_TEMPLATE" | sed "s#_SHARE_DIR_#$mount_dir#g; s#_VOLUME_NAME_#$vol_name#g" >"$SAMBA_CONF_DIR/${vol_name}.conf"
update_include_conf_file
send_reload_command
;;
preumount )
vol_name=$3
send_close_share_command "$vol_name"
rm "$SAMBA_CONF_DIR/${vol_name}.conf" || true
update_include_conf_file
send_reload_command
;;
shutdown|bootup )
empty_conf_dir
;;
* )
# ignore all unsupported events
exit 0
;;
esac
exit 0