4 _root="$(dirname "${0}")"; . "${_root}/lib/env.sh"
11 echo "Insert help here"
14 # Parse command line options
15 while getopts "n:h" opt
18 n) name="${OPTARG}" ;;
20 [?]) pebkac "Unrecognized option ${opt}" ;;
23 shift $(( $OPTIND - 1 ))
28 [ -r "${src}" ] || err "${src}: no such file or directory"
29 [ ! -f "${out}" ] || err "${out}: file exists"
31 # mkisofs switch meanings
33 # -gui GUI-suitable status messages
34 # -D No deep directory relocation (and no RR_MOVED)
35 # -R Include rock-ridge extensions
36 # -no-pad Don't pad to 150 sectors
37 # -iso-level 4 iso8859:1999 standard
38 # -p CyberLeo Set preparer string
39 # -V <volname> Set volume label
40 # -o splat output filename
41 command="/usr/local/bin/mkisofs -v -gui -D -R -no-pad -iso-level 4 -p CyberLeo -V '${name}' -o '${out}' '${src}' 2>&1"
43 time_start="$(date +%s)"
45 eval ${command} | sed -l -e '/^Writing: *The File(s).*$/s/^.*$/started=1 total=10000/; s/^\([ 0-9.%]*\) done.*$/count=\1/; /^[0-9]* extents written/s/^.*$/finished=1/; /=/!d; /^count=/s/[ .%]//g' | while read line
54 iter="$(( ${iter:-0} + 1 ))"
56 if [ -n "${finished}" -o "$(( ${iter} % ${limit_break:-16} ))" -eq 0 ] && \
57 [ -n "${finished}" -o "$(date +%s)" != "${time_last}" ]
61 iter_diff="$(( ${iter:-0} - ${iter_last:-0} ))"
62 time_diff="$(( ${time} - ${time_last:-0} ))"
64 # Adjust last iteration length as a rolling average of half the last per-second cluster count
65 [ -z "${finished}" ] && limit_break="$(( ( ${limit_break:-16} + ( ( ${iter_diff} / ${time_diff} ) / 2 ) ) / 2 ))"
66 [ "${limit_break}" -eq 0 ] && limit_break=1 # Avoid divide-by-zero errors
68 iter_last="${iter:-0}"
71 [ -n "${finished}" ] && count="${total}"
73 printf "\r %s\033[K" "$(progress "${count}" "${total}")"
75 [ -n "${finished}" ] && printf "\n"