/usr/sbin/ocs-tune-conf-for-webdav is in clonezilla 3.21.13-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/bin/bash
# License: GPL
# Author: Steven Shiau <steven _at_ nchc org tw>
# Description: Program to assign a friendly davfs2 setting for uploading Clonezilla image:
# It will modify the following parameters in /etc/davfs2/davfs2.conf and /etc/drbl/drbl-ocs.conf. This will only be done in DRBL/Clonezilla live env.
# For davfs2.conf:
# ===============
# buf_size 10240 #KiByte maybe more
# use_locks 0
# use_expect100 1
# use_compression 1
# cache_size 64 #MiByte maybe more, dynamic
# delay_upload 0
# ===============
# For drbl-ocs.conf:
# ===============
# VOL_LIMIT_DEFAULT="1000000"
# VOL_LIMIT_IN_INTERACTIVE="4096"
# split_suf_len="2"
# ===============
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions
# Settings:
dav_conf="/etc/davfs2/davfs2.conf"
davfs2_params="buf_size use_locks use_expect100 use_compression cache_size delay_upload"
# Functions
get_davfs2_cache_size() {
cache_d_line="$(LC_ALL=C grep -q -E "^[[:space:]]*cache_dir" /etc/davfs2/davfs2.conf)"
if [ -n "$cache_d" ]; then
cache_d="$(LC_ALL=C echo $cache_d_line | awk -F" " '{print $2}')"
else
cache_d="/var/cache/davfs2"
fi
free_dsk_space="$(LC_ALL=C df -BM $cache_d | tail -n 1 | awk -F" " '{print $4}')"
# We set the cache size as 20% of the system.
cache_size="$(LC_ALL=C printf "%.0f" "$(echo "${free_dsk_space%M} * ${ratio_davfs2_cache_2_free_disk}" | bc -l)")"
echo "$cache_size"
} # end of get_davfs2_cache_size
############
### MAIN ###
############
# If it's not in DRBL/Clonezilla live env, exit.
if ! is_drbl_clonezilla_live_env; then
exit 1
fi
davfs2_cache_size="$(get_davfs2_cache_size)" # MiByte
[ -z "$davfs2_cache_size" ] && davfs2_cache_size="$davfs2_cache_size_def"
# ///NOTE/// The cache mechanism of davfs2 is a problem (ref: https://sourceforge.net/forum/forum.php?thread_id=2248597&forum_id=82589). Although we use ratio_davfs2_cache_2_free_disk and free ramdisk space to set the cache size of davfs2, according to "man davfs2.conf":
# cache_size: The amount of disk space in MiByte that may be used. mount.davfs will always take enough space to cache open files, ignoring this value if necessary.
# Therefore the cache_size get in ocs-tune-conf-for-webdav is actually applied to VOL_LIMIT_DEFAULT and VOL_LIMIT_IN_INTERACTIVE, too, so that single file won't be over size.
# volume size in drbl-ocs.conf has to be adjusted, too.
perl -pi -e "s/^VOL_LIMIT_DEFAULT=.*/VOL_LIMIT_DEFAULT=$davfs2_cache_size # Modified by prep-ocsroot for davfs2/" /etc/drbl/drbl-ocs.conf
perl -pi -e "s/^VOL_LIMIT_IN_INTERACTIVE=.*/VOL_LIMIT_IN_INTERACTIVE=$davfs2_cache_size # Modified by prep-ocsroot for davfs2/" /etc/drbl/drbl-ocs.conf
# Change split suffixes of length to 3 so that the total size for single image file could be large enough.
perl -pi -e "s/^split_suf_len=.*/split_suf_len=$davfs2_split_suf_len_def # Modified by prep-ocsroot for davfs2/" /etc/drbl/drbl-ocs.conf
echo "Tuning davfs2 parameters in $dav_conf..."
for id in $davfs2_params; do
eval rid=\$davfs2_$id
if grep -q -E "^$id[[:space:]]+" $dav_conf; then
# found the old one, replace that
perl -pi -e "s|^$id\s.*|$id $rid|g" $dav_conf
else
# old one does not exist, create one
cat <<-EOF >> $dav_conf
$id $rid
EOF
fi
done
|